General Overview¶

-When doing research on syntopic weather systems, it is important to see their virtical structure by taking crossections with respesct to height levels. The purpose of this notebook is to explore a method to scan an area by vertical cross sections and to either draw a plot or returning a video (Essentially generated by Matplotlib.FuncAnimation()).

-Packages involved: xarray, matplotlib, cartopy, numpy, and metpy.
-Other than one interactive function, the notebook has all parameters for function set up to run. However, there were tons of work done for standardization, so feel free to change the variable you want to look at after you walk through this notebook.
-You don't really need to type any code, this is just for let you get familar with the funtions in this package!

In [ ]:
import xarray as xr, matplotlib.pyplot as plt, numpy as np
import metpy.calc as mpcalc
import matplotlib.colors as mplc
from metpy.units import units
import Scanner

The data we use here is from ERA5 dataset. Theoretically, the data can generate crossections from any dataset retrieved from ERA5 dataset as long as the variables in the dataset includes temperature and geopotential height.

-At first, we need to read the data by xarray function.
-Because the default names in the dataset is too long, we should change some variables/coordinate's name at first.
(You don't need to do this step at all if you are comfortable with the default!)
-Potential temperature and vorticity will be used later. Because we don't have them in the raw dataset, we need to calculate them by metpy function (mpcalc.potential_temperature()).

In [ ]:
ds=xr.open_dataset('./testdata/feb1512z.grib', engine='cfgrib')
ds=ds.metpy.quantify()
ds=ds.rename({"isobaricInhPa":"pressure","latitude":"lat", "longitude":"lon"})
 #You need to process some data at first before puting it into function
ds['thta']=mpcalc.potential_temperature(ds.pressure, ds.t) #We don't have thta at beginning 
ds['vo'] = mpcalc.vorticity(ds.u,ds.v)
ds['z']=ds.z/9.8 #To calculate geopotential height, the value need to be devided by $g$
#Take a look with the processed dataset!
ds
Ignoring index file './testdata/feb1512z.grib.923a8.idx' incompatible with GRIB file
/home/wen/anaconda3/envs/plot/lib/python3.10/site-packages/metpy/xarray.py:355: UserWarning: More than one time coordinate present for variable "u".
  warnings.warn('More than one ' + axis + ' coordinate present for variable'
Out[ ]:
<xarray.Dataset>
Dimensions:     (pressure: 27, lat: 121, lon: 281)
Coordinates:
    number      int64 0
    time        datetime64[ns] 2023-02-15T12:00:00
    step        timedelta64[ns] 00:00:00
  * pressure    (pressure) float64 1e+03 975.0 950.0 925.0 ... 150.0 125.0 100.0
  * lat         (lat) float64 50.0 49.75 49.5 49.25 ... 20.75 20.5 20.25 20.0
  * lon         (lon) float64 -140.0 -139.8 -139.5 -139.2 ... -70.5 -70.25 -70.0
    valid_time  datetime64[ns] 2023-02-15T12:00:00
Data variables:
    z           (pressure, lat, lon) float32 <Quantity([[[   91.4202      90....
    pv          (pressure, lat, lon) float32 <Quantity([[[-1.2834789e-08 -1.6...
    t           (pressure, lat, lon) float32 <Quantity([[[278.68237 278.63745...
    u           (pressure, lat, lon) float32 <Quantity([[[  9.163666    9.189...
    v           (pressure, lat, lon) float32 <Quantity([[[-2.067749   -2.3909...
    w           (pressure, lat, lon) float32 <Quantity([[[-2.88496017e-02 -3....
    thta        (pressure, lat, lon) float64 <Quantity([[[278.68237305 278.63...
    vo          (pressure, lat, lon) float64 <Quantity([[[-2.91261154e-05 -2....
Attributes:
    GRIB_edition:            1
    GRIB_centre:             ecmf
    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             European Centre for Medium-Range Weather Forecasts
    history:                 2024-01-24T17:04 GRIB to CDM+CF via cfgrib-0.9.1...
xarray.Dataset
    • pressure: 27
    • lat: 121
    • lon: 281
    • number
      ()
      int64
      0
      long_name :
      ensemble member numerical id
      units :
      1
      standard_name :
      realization
      array(0)
    • time
      ()
      datetime64[ns]
      2023-02-15T12:00:00
      long_name :
      initial time of forecast
      standard_name :
      forecast_reference_time
      array('2023-02-15T12:00:00.000000000', dtype='datetime64[ns]')
    • step
      ()
      timedelta64[ns]
      00:00:00
      long_name :
      time since forecast_reference_time
      standard_name :
      forecast_period
      array(0, dtype='timedelta64[ns]')
    • pressure
      (pressure)
      float64
      1e+03 975.0 950.0 ... 125.0 100.0
      long_name :
      pressure
      units :
      hPa
      positive :
      down
      stored_direction :
      decreasing
      standard_name :
      air_pressure
      _metpy_axis :
      vertical
      array([1000.,  975.,  950.,  925.,  900.,  875.,  850.,  825.,  800.,  775.,
              750.,  700.,  650.,  600.,  550.,  500.,  450.,  400.,  350.,  300.,
              250.,  225.,  200.,  175.,  150.,  125.,  100.])
    • lat
      (lat)
      float64
      50.0 49.75 49.5 ... 20.5 20.25 20.0
      units :
      degrees_north
      standard_name :
      latitude
      long_name :
      latitude
      stored_direction :
      decreasing
      _metpy_axis :
      y,latitude
      array([50.  , 49.75, 49.5 , 49.25, 49.  , 48.75, 48.5 , 48.25, 48.  , 47.75,
             47.5 , 47.25, 47.  , 46.75, 46.5 , 46.25, 46.  , 45.75, 45.5 , 45.25,
             45.  , 44.75, 44.5 , 44.25, 44.  , 43.75, 43.5 , 43.25, 43.  , 42.75,
             42.5 , 42.25, 42.  , 41.75, 41.5 , 41.25, 41.  , 40.75, 40.5 , 40.25,
             40.  , 39.75, 39.5 , 39.25, 39.  , 38.75, 38.5 , 38.25, 38.  , 37.75,
             37.5 , 37.25, 37.  , 36.75, 36.5 , 36.25, 36.  , 35.75, 35.5 , 35.25,
             35.  , 34.75, 34.5 , 34.25, 34.  , 33.75, 33.5 , 33.25, 33.  , 32.75,
             32.5 , 32.25, 32.  , 31.75, 31.5 , 31.25, 31.  , 30.75, 30.5 , 30.25,
             30.  , 29.75, 29.5 , 29.25, 29.  , 28.75, 28.5 , 28.25, 28.  , 27.75,
             27.5 , 27.25, 27.  , 26.75, 26.5 , 26.25, 26.  , 25.75, 25.5 , 25.25,
             25.  , 24.75, 24.5 , 24.25, 24.  , 23.75, 23.5 , 23.25, 23.  , 22.75,
             22.5 , 22.25, 22.  , 21.75, 21.5 , 21.25, 21.  , 20.75, 20.5 , 20.25,
             20.  ])
    • lon
      (lon)
      float64
      -140.0 -139.8 ... -70.25 -70.0
      units :
      degrees_east
      standard_name :
      longitude
      long_name :
      longitude
      _metpy_axis :
      x,longitude
      array([-140.  , -139.75, -139.5 , ...,  -70.5 ,  -70.25,  -70.  ])
    • valid_time
      ()
      datetime64[ns]
      2023-02-15T12:00:00
      standard_name :
      time
      long_name :
      time
      array('2023-02-15T12:00:00.000000000', dtype='datetime64[ns]')
    • z
      (pressure, lat, lon)
      float32
      <Quantity([[[ 91.4202 90....
      Magnitude
      [[[91.42019653320312 90.69316101074219 90.00437927246094 ...
      101.79010009765625 102.19825744628906 102.51713562011719]
      [93.81816101074219 93.07836151123047 92.42784881591797 ...
      102.03244018554688 102.78499603271484 103.90744018554688]
      [96.05030059814453 95.46356964111328 94.83856964111328 ...
      102.47887420654297 103.35897064208984 104.83856964111328]
      ...
      [150.9865264892578 152.10897827148438 153.0528564453125 ...
      173.5120391845703 173.8436737060547 174.23907470703125]
      [149.80029296875 150.88449096679688 151.67529296875 ...
      173.12937927246094 173.23141479492188 173.47377014160156]
      [148.61407470703125 149.45591735839844 149.9661102294922 ...
      172.47886657714844 172.60641479492188 173.0911102294922]]

      [[297.870361328125 297.1050720214844 296.4418029785156 ...
      302.6918029785156 303.1509704589844 303.48260498046875]
      [300.3448486328125 299.5795593261719 298.9162902832031 ...
      303.48260498046875 304.3244323730469 305.4468994140625]
      [302.6280212402344 302.0030212402344 301.3525085449219 ...
      304.643310546875 305.5744323730469 307.0030212402344]
      ...
      [368.6484375 369.73260498046875 370.5871887207031 ...
      394.26068115234375 394.6177978515625 395.0514831542969]
      [367.5132141113281 368.5208740234375 369.222412109375 ...
      393.7504577636719 393.9800720214844 394.222412109375]
      [366.3525085449219 367.1178283691406 367.5514831542969 ...
      392.972412109375 393.4443359375 393.9800720214844]]

      [[508.1432189941406 507.36517333984375 506.66363525390625 ...
      507.6330261230469 508.1942443847656 508.64068603515625]
      [510.6814880371094 509.9034423828125 509.18914794921875 ...
      508.9850769042969 509.8779296875 511.0003662109375]
      [513.0284423828125 512.3651733398438 511.65087890625 ...
      510.8473205566406 511.8294372558594 513.1942749023438]
      ...
      [590.349853515625 591.395751953125 592.1993408203125 ...
      619.0743408203125 619.4824829101562 619.928955078125]
      [589.2656860351562 590.2222900390625 590.8600463867188 ...
      618.52587890625 618.8447265625 619.1126098632812]
      [588.2197265625 588.9340209960938 589.2911987304688 ...
      617.5565185546875 618.2835083007812 618.8829956054688]]

      ...

      [[13397.06640625 13399.9228515625 13402.7802734375 ... 13455.53515625
      13455.126953125 13454.56640625]
      [13400.484375 13403.291015625 13406.1982421875 ... 13463.443359375
      13463.1376953125 13462.8310546875]
      [13403.80078125 13406.658203125 13409.56640625 ... 13471.25
      13471.0966796875 13471.0458984375]
      ...
      [14009.3623046875 14010.53515625 14010.1787109375 ... 14183.291015625
      14182.576171875 14181.810546875]
      [14013.0869140625 14014.66796875 14014.4638671875 ... 14185.484375
      14184.7705078125 14184.0556640625]
      [14016.40234375 14018.03515625 14017.93359375 ... 14187.525390625
      14186.8623046875 14186.1982421875]]

      [[14593.3095703125 14595.65625 14598.0546875 ... 14631.5244140625
      14631.6259765625 14631.6767578125]
      [14596.5751953125 14598.87109375 14601.3203125 ... 14638.7177734375
      14638.97265625 14639.0751953125]
      [14599.73828125 14602.1357421875 14604.5341796875 ... 14645.8095703125
      14646.1162109375 14646.3203125]
      ...
      [15111.013671875 15110.60546875 15109.431640625 ... 15285.197265625
      15284.6875 15284.0751953125]
      [15115.60546875 15115.2998046875 15113.87109375 ... 15287.1357421875
      15286.5751953125 15286.064453125]
      [15119.9423828125 15119.73828125 15118.2587890625 ... 15288.87109375
      15288.3603515625 15287.9013671875]]

      [[16033.03515625 16034.974609375 16036.9130859375 ... 16053.2392578125
      16052.908203125 16052.4482421875]
      [16035.53515625 16037.474609375 16039.4130859375 ... 16059.0302734375
      16058.724609375 16058.1376953125]
      [16038.03515625 16040.0 16041.9130859375 ... 16064.56640625
      16064.208984375 16063.5712890625]
      ...
      [16413.8515625 16412.728515625 16411.68359375 ... 16596.556640625
      16596.453125 16596.25]
      [16418.111328125 16416.607421875 16415.0 ... 16597.294921875
      16597.142578125 16596.96484375]
      [16422.5 16420.96875 16418.927734375 ... 16597.984375 16597.83203125
      16597.626953125]]]
      Unitsmeter2/second2
    • pv
      (pressure, lat, lon)
      float32
      <Quantity([[[-1.2834789e-08 -1.6...
      GRIB_paramId :
      60
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      unknown
      GRIB_cfVarName :
      pv
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      Potential vorticity
      GRIB_shortName :
      pv
      GRIB_totalNumber :
      0
      GRIB_units :
      K m**2 kg**-1 s**-1
      long_name :
      Potential vorticity
      standard_name :
      unknown
      Magnitude
      [[[-1.2834789231419563e-08 -1.6560079529881477e-08
      -2.773595042526722e-08 ... 2.907792804762721e-06
      3.511289833113551e-06 3.082881448790431e-06]
      [-9.10949893295765e-09 -1.2834789231419563e-08 -2.028536982834339e-08
      ... 1.8013815861195326e-06 3.816763637587428e-06
      3.7534337025135756e-06]
      [-5.384208634495735e-09 -9.10949893295765e-09 -1.6560079529881477e-08
      ... 3.224413376301527e-07 2.348999259993434e-06 6.465445039793849e-06]
      ...
      [-1.6589183360338211e-09 -1.6589183360338211e-09 2.066371962428093e-09
      ... -1.6589183360338211e-09 2.066371962428093e-09
      -1.6589183360338211e-09]
      [-5.384208634495735e-09 -5.384208634495735e-09 -1.6589183360338211e-09
      ... -1.6560079529881477e-08 2.066371962428093e-09
      -1.6589183360338211e-09]
      [-1.6589183360338211e-09 -1.6589183360338211e-09 5.791662260890007e-09
      ... -1.6560079529881477e-08 -1.6589183360338211e-09
      -5.384208634495735e-09]]

      [[-5.384208634495735e-09 2.066371962428093e-09 5.791662260890007e-09
      ... 2.907792804762721e-06 3.511289833113551e-06 3.082881448790431e-06]
      [-5.384208634495735e-09 5.791662260890007e-09 5.791662260890007e-09
      ... 1.8013815861195326e-06 3.816763637587428e-06
      3.7534337025135756e-06]
      [-1.6589183360338211e-09 1.3242242857813835e-08 1.696753315627575e-08
      ... 3.224413376301527e-07 2.348999259993434e-06 6.465445039793849e-06]
      ...
      [5.791662260890007e-09 5.791662260890007e-09 9.516952559351921e-09 ...
      2.066371962428093e-09 2.066371962428093e-09 2.066371962428093e-09]
      [5.791662260890007e-09 5.791662260890007e-09 5.791662260890007e-09 ...
      5.791662260890007e-09 2.066371962428093e-09 2.066371962428093e-09]
      [1.3242242857813835e-08 2.4418113753199577e-08 2.4418113753199577e-08
      ... 2.0692823454737663e-08 5.791662260890007e-09
      -1.6589183360338211e-09]]

      [[7.657217793166637e-08 8.029746823012829e-08 8.40227585285902e-08 ...
      2.0248990040272474e-06 2.6283960323780775e-06 2.5501649361103773e-06]
      [6.539630703628063e-08 6.912159733474255e-08 7.657217793166637e-08 ...
      9.855430107563734e-07 1.6709964256733656e-06 1.693348167464137e-06]
      [5.0495145842432976e-08 6.539630703628063e-08 7.284688763320446e-08
      ... 2.702872734516859e-07 9.5946597866714e-07 3.831664798781276e-06]
      ...
      [1.3245153240859509e-07 1.36176822707057e-07 1.2500095181167126e-07
      ... 1.2872624211013317e-07 1.3245153240859509e-07
      1.883308868855238e-07]
      [1.4362740330398083e-07 1.5107798390090466e-07 1.2500095181167126e-07
      ... 1.1755037121474743e-07 1.3245153240859509e-07
      1.920561771839857e-07]
      [1.5480327419936657e-07 1.5852856449782848e-07 1.2500095181167126e-07
      ... 1.5480327419936657e-07 1.5852856449782848e-07
      1.36176822707057e-07]]

      ...

      [[6.495786692539696e-06 6.432456757465843e-06 6.39799782220507e-06 ...
      7.0890391725697555e-06 7.060168172756676e-06 7.079725946823601e-06]
      [6.556322659889702e-06 6.491130079666618e-06 6.424074854294304e-06 ...
      7.013602044025902e-06 6.993112947384361e-06 7.010808076302055e-06]
      [6.613133336941246e-06 6.5209324020543136e-06 6.453877176681999e-06
      ... 6.951203431526665e-06 6.930714334885124e-06 6.908362593094353e-06]
      ...
      [8.221695679822005e-07 7.532516974606551e-07 6.424243110814132e-07 ...
      9.274090189137496e-07 9.311343092122115e-07 9.348595995106734e-07]
      [8.687356967129745e-07 8.137876648106612e-07 6.787458914914168e-07 ...
      8.482466000714339e-07 8.491779226460494e-07 8.519718903698958e-07]
      [9.832883733906783e-07 9.329969543614425e-07 7.932985681691207e-07 ...
      7.662902135052718e-07 7.709468263783492e-07 7.923672455945052e-07]]

      [[7.2271504905074835e-06 6.75403862260282e-06 6.280926754698157e-06 ...
      6.3144543673843145e-06 6.018293788656592e-06 5.617825081571937e-06]
      [7.155438652262092e-06 6.674876203760505e-06 6.14029704593122e-06 ...
      6.755901267752051e-06 6.387097528204322e-06 5.986628821119666e-06]
      [7.090246072039008e-06 6.561254849657416e-06 6.023881724104285e-06 ...
      7.152644684538245e-06 6.781046977266669e-06 6.443908205255866e-06]
      ...
      [1.8282735254615545e-06 1.6857811715453863e-06 1.6084813978523016e-06
      ... 1.5572586562484503e-06 1.5302503015846014e-06
      1.4939287211745977e-06]
      [1.79008929990232e-06 1.6615667846053839e-06 1.5190744306892157e-06
      ... 1.4883407857269049e-06 1.4780962374061346e-06
      1.4566758181899786e-06]
      [1.7444544937461615e-06 1.6662233974784613e-06 1.5172117855399847e-06
      ... 1.4622637536376715e-06 1.441774656996131e-06
      1.422216882929206e-06]]

      [[1.1575801181606948e-05 1.123773108702153e-05 1.0935982572846115e-05
      ... 9.210241842083633e-06 9.205585229210556e-06 9.016526746563613e-06]
      [1.1212585377506912e-05 1.0872652637772262e-05 1.0554140317253768e-05
      ... 9.077994036488235e-06 8.86472116690129e-06 8.661692845635116e-06]
      [1.0876377928070724e-05 1.051875005941838e-05 1.0198375093750656e-05
      ... 8.824674296192825e-06 8.61140142660588e-06 8.496848749928176e-06]
      ...
      [3.1929666874930263e-06 3.1920353649184108e-06 3.114735591225326e-06
      ... 8.39514541439712e-07 8.497590897604823e-07 8.711795089766383e-07]
      [3.1296367524191737e-06 3.19017271976918e-06 3.2888929126784205e-06
      ... 6.68151187710464e-07 7.044727681204677e-07 7.510388968512416e-07]
      [3.1119416235014796e-06 3.266541170887649e-06 3.4658442018553615e-06
      ... 5.964393494650722e-07 6.23447704128921e-07 6.569753168150783e-07]]]
      Unitskelvin meter2/(kilogram second)
    • t
      (pressure, lat, lon)
      float32
      <Quantity([[[278.68237 278.63745...
      GRIB_paramId :
      130
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      air_temperature
      GRIB_cfVarName :
      t
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      Temperature
      GRIB_shortName :
      t
      GRIB_totalNumber :
      0
      GRIB_units :
      K
      long_name :
      Temperature
      standard_name :
      air_temperature
      Magnitude
      [[[278.682373046875 278.637451171875 278.633544921875 ...
      271.428466796875 271.594482421875 271.754638671875]
      [278.744873046875 278.725341796875 278.711669921875 ...
      272.240966796875 272.489013671875 272.514404296875]
      [278.799560546875 278.797607421875 278.758544921875 ...
      273.203857421875 273.377685546875 273.280029296875]
      ...
      [292.479248046875 292.438232421875 292.369873046875 ...
      296.410888671875 296.428466796875 296.393310546875]
      [292.524169921875 292.457763671875 292.367919921875 ...
      296.237060546875 296.434326171875 296.455810546875]
      [292.526123046875 292.446044921875 292.346435546875 ...
      295.901123046875 296.311279296875 296.473388671875]]

      [[276.68853759765625 276.63580322265625 276.59478759765625 ...
      270.10260009765625 270.34283447265625 270.48150634765625]
      [276.73736572265625 276.70220947265625 276.67095947265625 ...
      271.09869384765625 271.30377197265625 271.04791259765625]
      [276.81549072265625 276.77056884765625 276.72174072265625 ...
      272.04205322265625 272.01666259765625 271.74322509765625]
      ...
      [290.39556884765625 290.35455322265625 290.29791259765625 ...
      294.27252197265625 294.27252197265625 294.25494384765625]
      [290.42291259765625 290.35455322265625 290.30767822265625 ...
      294.15533447265625 294.29595947265625 294.30963134765625]
      [290.43853759765625 290.36627197265625 290.31744384765625 ...
      293.84283447265625 294.11627197265625 294.30572509765625]]

      [[274.68994140625 274.65283203125 274.59033203125 ... 268.25634765625
      268.47509765625 268.19580078125]
      [274.74658203125 274.71728515625 274.61767578125 ... 268.56884765625
      268.60009765625 268.26025390625]
      [274.78955078125 274.75439453125 274.66259765625 ... 270.09619140625
      269.64111328125 269.02392578125]
      ...
      [288.68017578125 288.60009765625 288.52001953125 ... 292.24267578125
      292.40478515625 292.57861328125]
      [288.80322265625 288.70361328125 288.58251953125 ... 292.20751953125
      292.28369140625 292.43408203125]
      [288.95947265625 288.93994140625 288.84033203125 ... 292.05322265625
      292.11767578125 292.21728515625]]

      ...

      [[225.69151306152344 225.59873962402344 225.50987243652344 ...
      221.01963806152344 221.16612243652344 221.32432556152344]
      [225.58702087402344 225.50108337402344 225.42491149902344 ...
      220.83604431152344 221.01573181152344 221.19053649902344]
      [225.47862243652344 225.39170837402344 225.32334899902344 ...
      220.62705993652344 220.81553649902344 220.97471618652344]
      ...
      [208.79014587402344 208.55870056152344 208.32823181152344 ...
      209.40733337402344 209.44053649902344 209.46592712402344]
      [208.87120056152344 208.64561462402344 208.37998962402344 ...
      209.40830993652344 209.44932556152344 209.48448181152344]
      [208.96299743652344 208.78135681152344 208.52940368652344 ...
      209.39561462402344 209.44151306152344 209.48643493652344]]

      [[222.0879669189453 222.0274200439453 221.9600372314453 ...
      219.0137481689453 219.0713653564453 219.0996856689453]
      [222.0664825439453 221.9903106689453 221.9043731689453 ...
      218.8057403564453 218.8643341064453 218.8858184814453]
      [222.0655059814453 221.9727325439453 221.8672637939453 ...
      218.6016387939453 218.6309356689453 218.6162872314453]
      ...
      [203.4561309814453 203.2090606689453 203.2500762939453 ...
      203.8594512939453 203.8994903564453 203.9405059814453]
      [203.6446075439453 203.2969512939453 203.2559356689453 ...
      203.7530059814453 203.7842559814453 203.8135528564453]
      [203.8291778564453 203.4756622314453 203.3838653564453 ...
      203.6660919189453 203.6836700439453 203.6983184814453]]

      [[218.73048400878906 218.55958557128906 218.36817932128906 ...
      215.92189025878906 215.72755432128906 215.53419494628906]
      [218.61329650878906 218.46681213378906 218.29396057128906 ...
      215.81349182128906 215.58692932128906 215.35548400878906]
      [218.50782775878906 218.38380432128906 218.22853088378906 ...
      215.75880432128906 215.51954650878906 215.26856994628906]
      ...
      [194.93067932128906 194.84376525878906 194.81153869628906 ...
      197.13673400878906 197.18360900878906 197.22755432128906]
      [194.65626525878906 194.56349182128906 194.56544494628906 ...
      196.94630432128906 196.99903869628906 197.04396057128906]
      [194.52345275878906 194.39942932128906 194.39259338378906 ...
      196.76368713378906 196.82228088378906 196.86720275878906]]]
      Unitskelvin
    • u
      (pressure, lat, lon)
      float32
      <Quantity([[[ 9.163666 9.189...
      GRIB_paramId :
      131
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      eastward_wind
      GRIB_cfVarName :
      u
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      U component of wind
      GRIB_shortName :
      u
      GRIB_totalNumber :
      0
      GRIB_units :
      m s**-1
      long_name :
      U component of wind
      standard_name :
      eastward_wind
      Magnitude
      [[[9.163665771484375 9.189056396484375 9.124603271484375 ...
      1.151947021484375 1.449798583984375 1.407806396484375]
      [8.947845458984375 8.960540771484375 8.901947021484375 ...
      1.330657958984375 1.482025146484375 1.280853271484375]
      [8.720306396484375 8.718353271484375 8.724212646484375 ...
      1.721282958984375 1.728118896484375 1.299407958984375]
      ...
      [-10.174224853515625 -10.043365478515625 -9.918365478515625 ...
      -8.134185791015625 -7.975982666015625 -7.749420166015625]
      [-10.247467041015625 -10.139068603515625 -10.035552978515625 ...
      -8.168365478515625 -8.054107666015625 -7.766021728515625]
      [-10.461334228515625 -10.481842041015625 -10.464263916015625 ...
      -7.766021728515625 -7.753326416015625 -7.494537353515625]]

      [[9.6484375 9.6884765625 9.6103515625 ... 1.0966796875 1.5126953125
      1.5380859375]
      [9.392578125 9.4267578125 9.392578125 ... 1.345703125 1.4658203125
      1.267578125]
      [9.123046875 9.140625 9.20703125 ... 1.7158203125 1.5927734375
      1.271484375]
      ...
      [-10.603515625 -10.4140625 -10.2734375 ... -8.388671875 -8.2412109375
      -8.015625]
      [-10.689453125 -10.515625 -10.3935546875 ... -8.4794921875
      -8.3115234375 -7.986328125]
      [-10.876953125 -10.783203125 -10.7919921875 ... -8.3515625
      -8.1318359375 -7.755859375]]

      [[10.025955200195312 10.065017700195312 10.093338012695312 ...
      1.9341583251953125 2.2515411376953125 1.9595489501953125]
      [9.754470825195312 9.835525512695312 9.891189575195312 ...
      3.3032989501953125 3.3286895751953125 2.6656036376953125]
      [9.480056762695312 9.546463012695312 9.662673950195312 ...
      2.8101348876953125 2.9517364501953125 2.7564239501953125]
      ...
      [-10.886154174804688 -10.516036987304688 -10.175216674804688 ...
      -8.560958862304688 -8.430099487304688 -8.137130737304688]
      [-10.796310424804688 -10.478927612304688 -10.334396362304688 ...
      -8.728927612304688 -8.644943237304688 -8.250411987304688]
      [-10.504318237304688 -10.304122924804688 -10.432052612304688 ...
      -8.540451049804688 -8.516036987304688 -8.078536987304688]]

      ...

      [[10.038864135742188 10.036911010742188 10.034957885742188 ...
      26.628707885742188 26.497848510742188 26.316207885742188]
      [10.294723510742188 10.341598510742188 10.372848510742188 ...
      26.687301635742188 26.546676635742188 26.322067260742188]
      [10.552536010742188 10.658004760742188 10.745895385742188 ...
      26.693161010742188 26.527145385742188 26.263473510742188]
      ...
      [34.63652038574219 34.45878601074219 34.83573913574219 ...
      20.531051635742188 20.661911010742188 20.763473510742188]
      [34.17362976074219 33.77714538574219 34.05839538574219 ...
      20.302536010742188 20.447067260742188 20.560348510742188]
      [34.01347351074219 33.44511413574219 33.53105163574219 ...
      20.019332885742188 20.173629760742188 20.294723510742188]]

      [[9.740020751953125 9.966583251953125 10.199005126953125 ...
      21.398223876953125 21.138458251953125 20.876739501953125]
      [9.640411376953125 9.825958251953125 10.021270751953125 ...
      21.243927001953125 20.882598876953125 20.538848876953125]
      [9.546661376953125 9.681427001953125 9.824005126953125 ...
      21.113067626953125 20.687286376953125 20.318145751953125]
      ...
      [26.425567626953125 26.782989501953125 27.040802001953125 ...
      14.447052001953125 14.669708251953125 14.904083251953125]
      [25.968536376953125 26.472442626953125 26.950958251953125 ...
      14.185333251953125 14.398223876953125 14.616973876953125]
      [25.663848876953125 26.120880126953125 26.657989501953125 ...
      13.907989501953125 14.103302001953125 14.320098876953125]]

      [[10.98968505859375 10.75335693359375 10.53656005859375 ...
      22.05609130859375 22.19281005859375 22.37445068359375]
      [11.39202880859375 11.14007568359375 10.89398193359375 ...
      22.18304443359375 22.29241943359375 22.47601318359375]
      [11.76507568359375 11.50335693359375 11.23382568359375 ...
      22.35491943359375 22.41741943359375 22.59124755859375]
      ...
      [24.45452880859375 25.57562255859375 26.49945068359375 ...
      7.83734130859375 7.79632568359375 7.75140380859375]
      [24.45843505859375 25.68304443359375 26.77288818359375 ...
      7.59906005859375 7.54437255859375 7.49163818359375]
      [24.57366943359375 25.72015380859375 26.91156005859375 ...
      7.25921630859375 7.18890380859375 7.14593505859375]]]
      Unitsmeter/second
    • v
      (pressure, lat, lon)
      float32
      <Quantity([[[-2.067749 -2.3909...
      GRIB_paramId :
      132
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      northward_wind
      GRIB_cfVarName :
      v
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      V component of wind
      GRIB_shortName :
      v
      GRIB_totalNumber :
      0
      GRIB_units :
      m s**-1
      long_name :
      V component of wind
      standard_name :
      northward_wind
      Magnitude
      [[[-2.0677490234375 -2.3909912109375 -2.5872802734375 ...
      1.9127197265625 1.7525634765625 1.6832275390625]
      [-1.9066162109375 -2.2435302734375 -2.4749755859375 ...
      1.8931884765625 1.8375244140625 1.8931884765625]
      [-1.6917724609375 -2.0716552734375 -2.5247802734375 ...
      2.4439697265625 2.2408447265625 2.0494384765625]
      ...
      [1.2545166015625 1.0924072265625 0.9742431640625 ... -1.7015380859375
      -1.8909912109375 -2.0814208984375]
      [1.1715087890625 0.9683837890625 0.8062744140625 ... -0.9144287109375
      -1.5130615234375 -1.9603271484375]
      [0.9498291015625 0.6226806640625 0.3336181640625 ... 0.5318603515625
      -0.4261474609375 -1.4368896484375]]

      [[-2.253143310546875 -2.603729248046875 -2.803924560546875 ...
      1.667755126953125 1.722442626953125 1.875762939453125]
      [-2.031463623046875 -2.466033935546875 -2.732635498046875 ...
      2.043731689453125 2.010528564453125 1.857208251953125]
      [-1.842987060546875 -2.277557373046875 -2.770721435546875 ...
      2.396270751953125 2.129669189453125 1.975372314453125]
      ...
      [1.363067626953125 1.174591064453125 1.051544189453125 ...
      -1.717010498046875 -1.892791748046875 -2.067596435546875]
      [1.261505126953125 1.057403564453125 0.876739501953125 ...
      -0.973846435546875 -1.539276123046875 -1.949432373046875]
      [1.121856689453125 0.923614501953125 0.634552001953125 ...
      0.402130126953125 -0.531463623046875 -1.454315185546875]]

      [[-2.4107666015625 -2.9400634765625 -3.4010009765625 ...
      2.8236083984375 2.5521240234375 2.2083740234375]
      [-2.2662353515625 -2.9068603515625 -3.4732666015625 ...
      4.2005615234375 3.8529052734375 3.3802490234375]
      [-2.2037353515625 -2.8541259765625 -3.5963134765625 ...
      3.5032958984375 3.5423583984375 3.5540771484375]
      ...
      [1.7591552734375 1.3822021484375 1.0911865234375 ... -1.5377197265625
      -1.5474853515625 -1.6353759765625]
      [1.8236083984375 1.4017333984375 1.1107177734375 ... -1.0943603515625
      -1.4244384765625 -1.7056884765625]
      [1.7279052734375 1.4739990234375 1.3880615234375 ... 0.2454833984375
      -0.4302978515625 -1.3072509765625]]

      ...

      [[13.159088134765625 12.803619384765625 12.434478759765625 ...
      -2.684661865234375 -3.143646240234375 -3.557708740234375]
      [13.125885009765625 12.764556884765625 12.375885009765625 ...
      -2.538177490234375 -3.018646240234375 -3.438568115234375]
      [13.112213134765625 12.756744384765625 12.364166259765625 ...
      -2.294036865234375 -2.770599365234375 -3.178802490234375]
      ...
      [-7.712005615234375 -8.323333740234375 -8.823333740234375 ...
      -2.198333740234375 -2.368255615234375 -2.542083740234375]
      [-7.776458740234375 -8.704193115234375 -9.573333740234375 ...
      -1.754974365234375 -1.958099365234375 -2.165130615234375]
      [-7.479583740234375 -8.620208740234375 -9.827239990234375 ...
      -1.366302490234375 -1.590911865234375 -1.794036865234375]]

      [[14.410568237304688 14.404708862304688 14.267990112304688 ...
      -3.0347442626953125 -3.3023223876953125 -3.5738067626953125]
      [14.441818237304688 14.469161987304688 14.363693237304688 ...
      -2.9976348876953125 -3.1148223876953125 -3.2613067626953125]
      [14.430099487304688 14.482833862304688 14.398849487304688 ...
      -3.2827911376953125 -3.2613067626953125 -3.2906036376953125]
      ...
      [-0.8277130126953125 -1.0406036376953125 -1.0855255126953125 ...
      -7.3433380126953125 -7.4429473876953125 -7.5425567626953125]
      [-0.2163848876953125 -0.5855255126953125 -0.7261505126953125 ...
      -7.3921661376953125 -7.4937286376953125 -7.5894317626953125]
      [0.5863494873046875 0.0570526123046875 -0.1480255126953125 ...
      -7.4156036376953125 -7.5191192626953125 -7.6148223876953125]]

      [[8.282394409179688 8.143722534179688 7.9972381591796875 ...
      -4.1511993408203125 -4.2820587158203125 -4.4090118408203125]
      [8.288253784179688 8.110519409179688 7.9288787841796875 ...
      -4.3992462158203125 -4.6101837158203125 -4.8250274658203125]
      [8.360519409179688 8.161300659179688 7.9581756591796875 ...
      -4.5125274658203125 -4.8523712158203125 -5.1844024658203125]
      ...
      [7.5460662841796875 7.4484100341796875 7.0050506591796875 ...
      -3.1961212158203125 -3.5750274658203125 -3.9207305908203125]
      [6.3937225341796875 6.5480194091796875 6.3058319091796875 ...
      -3.2058868408203125 -3.5847930908203125 -3.9304962158203125]
      [4.9523162841796875 5.3273162841796875 5.3761444091796875 ...
      -3.2449493408203125 -3.6043243408203125 -3.9422149658203125]]]
      Unitsmeter/second
    • w
      (pressure, lat, lon)
      float32
      <Quantity([[[-2.88496017e-02 -3....
      GRIB_paramId :
      135
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      lagrangian_tendency_of_air_pressure
      GRIB_cfVarName :
      w
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      Vertical velocity
      GRIB_shortName :
      w
      GRIB_totalNumber :
      0
      GRIB_units :
      Pa s**-1
      long_name :
      Vertical velocity
      standard_name :
      lagrangian_tendency_of_air_pressure
      Magnitude
      [[[-0.02884960174560547 -0.03702831268310547 -0.03385448455810547 ...
      -0.10160350799560547 -0.08512401580810547 0.0033769607543945312]
      [-0.015177726745605469 -0.009562492370605469 -0.010783195495605469 ...
      -0.02579784393310547 -0.02457714080810547 0.03474903106689453]
      [-0.01810741424560547 -0.009806632995605469 -0.0028486251831054688 ...
      0.02815723419189453 0.01765918731689453 0.04463672637939453]
      ...
      [0.0030107498168945312 -0.004679679870605469 -0.0023603439331054688
      ... -0.010905265808105469 0.0026445388793945312 -0.006266593933105469]
      [0.009968757629394531 0.009358406066894531 0.02705860137939453 ...
      -0.09879589080810547 -0.02433300018310547 0.008870124816894531]
      [0.008015632629394531 0.007893562316894531 0.03731250762939453 ...
      -0.11173534393310547 -0.012858390808105469 -0.0029706954956054688]]

      [[-0.028978347778320312 -0.04997444152832031 -0.06474494934082031 ...
      -0.09855842590332031 -0.08000373840332031 0.0055675506591796875]
      [-0.03325080871582031 -0.025804519653320312 -0.019334793090820312 ...
      -0.04142951965332031 -0.020799636840820312 0.04963493347167969]
      [-0.031053543090820312 -0.009325027465820312 0.020093917846679688 ...
      0.030591964721679688 0.013868331909179688 0.03864860534667969]
      ...
      [0.020460128784179688 0.011304855346679688 -0.0004138946533203125 ...
      -0.04094123840332031 0.016798019409179688 0.022535324096679688]
      [0.03803825378417969 0.04401969909667969 0.06147575378417969 ...
      -0.2250232696533203 -0.06511116027832031 0.0008068084716796875]
      [0.027662277221679688 0.03181266784667969 0.07807731628417969 ...
      -0.2797107696533203 -0.06987190246582031 -0.06120491027832031]]

      [[-0.03022480010986328 -0.05512714385986328 -0.07380390167236328 ...
      -0.12690448760986328 -0.11311054229736328 -0.03852558135986328]
      [-0.04304218292236328 -0.03168964385986328 -0.013623237609863281 ...
      -0.07038593292236328 -0.02570819854736328 0.009814262390136719]
      [-0.03132343292236328 -0.00019550323486328125 0.05082988739013672 ...
      0.06340312957763672 0.07292461395263672 0.05314922332763672]
      ...
      [0.05229473114013672 0.03398418426513672 0.010790824890136719 ...
      -0.05695819854736328 0.04094219207763672 0.05339336395263672]
      [0.07695293426513672 0.07475566864013672 0.08244609832763672 ...
      -0.3396730422973633 -0.09504413604736328 0.0005369186401367188]
      [0.06010723114013672 0.02775859832763672 0.03166484832763672 ...
      -0.4265871047973633 -0.12702655792236328 -0.09711933135986328]]

      ...

      [[0.026823043823242188 0.028715133666992188 0.028165817260742188 ...
      0.016630172729492188 0.021085739135742188 0.030118942260742188]
      [0.024198532104492188 0.028226852416992188 0.028959274291992188 ...
      0.030302047729492188 0.028348922729492188 0.025541305541992188]
      [0.021574020385742188 0.027433395385742188 0.030118942260742188 ...
      0.04183769226074219 0.030363082885742188 0.013456344604492188]
      ...
      [-0.08462715148925781 -0.11752510070800781 -0.11044502258300781 ...
      -0.0063190460205078125 -0.0052814483642578125 -0.0077228546142578125]
      [-0.06308174133300781 -0.11587715148925781 -0.10684394836425781 ...
      -0.008028030395507812 -0.0071125030517578125 -0.009065628051757812]
      [-0.04403877258300781 -0.10116767883300781 -0.09079170227050781 ...
      -0.010713577270507812 -0.011629104614257812 -0.015535354614257812]]

      [[0.03841400146484375 0.04482269287109375 0.04946136474609375 ...
      -0.01035308837890625 -0.01792144775390625 -0.02487945556640625]
      [0.03414154052734375 0.04158782958984375 0.04665374755859375 ...
      -0.00461578369140625 -0.01621246337890625 -0.02951812744140625]
      [0.02993011474609375 0.03865814208984375 0.04457855224609375 ...
      -0.00418853759765625 -0.01999664306640625 -0.03910064697265625]
      ...
      [-0.09354400634765625 -0.05490875244140625 -0.01187896728515625 ...
      0.00167083740234375 0.00472259521484375 0.00545501708984375]
      [-0.13205718994140625 -0.10086822509765625 -0.03702545166015625 ...
      -0.00315093994140625 -0.00174713134765625 -0.00272369384765625]
      [-0.14353179931640625 -0.12973785400390625 -0.06449127197265625 ...
      -0.00540924072265625 -0.00669097900390625 -0.01010894775390625]]

      [[0.023909568786621094 0.019331932067871094 0.015120506286621094 ...
      -0.032731056213378906 -0.036026954650878906 -0.039750099182128906]
      [0.024580955505371094 0.020064353942871094 0.015608787536621094 ...
      -0.030411720275878906 -0.036637306213378906 -0.040970802307128906]
      [0.023848533630371094 0.020125389099121094 0.015913963317871094 ...
      -0.026566505432128906 -0.034379005432128906 -0.038163185119628906]
      ...
      [-0.041031837463378906 -0.023636817932128906 -0.006791114807128906 ...
      0.012984275817871094 0.011946678161621094 0.010481834411621094]
      [-0.058304786682128906 -0.033341407775878906 -0.005387306213378906 ...
      0.012984275817871094 0.010359764099121094 0.007674217224121094]
      [-0.0720987319946289 -0.048600196838378906 -0.010575294494628906 ...
      0.011702537536621094 0.008040428161621094 0.004866600036621094]]]
      Unitspascal/second
    • thta
      (pressure, lat, lon)
      float64
      <Quantity([[[278.68237305 278.63...
      Magnitude
      [[[278.682373046875 278.637451171875 278.633544921875 ...
      271.428466796875 271.594482421875 271.754638671875]
      [278.744873046875 278.725341796875 278.711669921875 ...
      272.240966796875 272.489013671875 272.514404296875]
      [278.799560546875 278.797607421875 278.758544921875 ...
      273.203857421875 273.377685546875 273.280029296875]
      ...
      [292.479248046875 292.438232421875 292.369873046875 ...
      296.410888671875 296.428466796875 296.393310546875]
      [292.524169921875 292.457763671875 292.367919921875 ...
      296.237060546875 296.434326171875 296.455810546875]
      [292.526123046875 292.446044921875 292.346435546875 ...
      295.901123046875 296.311279296875 296.473388671875]]

      [[278.69726471007056 278.64414748954414 278.6028340958014 ...
      272.0635140576654 272.30549250673 272.4451711236697]
      [278.74644732166905 278.7110358413181 278.6795589698951 ...
      273.0668393342747 273.2734063029884 273.0156894182123]
      [278.8251395002266 278.77989149755604 278.73070888595754 ...
      274.0170473903577 273.9914724323264 273.7160498073749]
      ...
      [292.50380743800036 292.46249404425765 292.4054422148034 ...
      296.40890679892095 296.40890679892095 296.3912010587455]
      [292.5313497004955 292.46249404425765 292.41527873712306 ...
      296.2908685310846 296.43251445248825 296.4462855837358]
      [292.54708813620704 292.47429787104124 292.42511525944275 ...
      295.9760998168542 296.2515224418058 296.44235097480794]]

      [[278.7452278337093 278.70757060776145 278.6441479114282 ...
      272.2166540299054 272.4386334670718 272.15521329283257]
      [278.8027046522613 278.7729752633551 278.671895341074 ...
      272.5337675115716 272.5654788597383 272.2206179484262]
      [278.84630775599044 278.810632489303 278.7174804040635 ...
      274.0836596532154 273.62186314553895 272.9955640192481]
      ...
      [292.94200201605526 292.8607416863783 292.7794813567013 ...
      296.5570957070505 296.72159832566484 296.8979926998417]
      [293.0668654494613 292.96578552718023 292.84290405303454 ...
      296.52142044036304 296.5987168515192 296.75132771457106]
      [293.22542219029447 293.2056025976903 293.1045226754092 ...
      296.36484565879033 296.430250314384 296.5313302366651]]

      ...

      [[388.07684020156165 387.9173161592472 387.7645089187144 ...
      380.04354527069535 380.29542533750765 380.5674558096649]
      [387.8971657539022 387.7493961147057 387.6184184799633 ...
      379.72785558695733 380.0368284689137 380.337405348643]
      [387.71077450446114 387.56132566481915 387.44378163364007 ...
      379.36850669163846 379.6925923776036 379.96630205020625]
      ...
      [359.014918092761 358.6169475871976 358.22065628207963 ...
      360.0761727742634 360.13326558940753 360.1769248009883]
      [359.15429172973046 358.76639642683955 358.3096539056866 ...
      360.0778519747088 360.14837839341624 360.2088296094512]
      [359.31213657159947 358.99980528875227 358.5665715738351 ...
      360.05602236891843 360.1349447898529 360.212188010342]]

      [[402.3006543734968 402.19097689852737 402.06891648283556 ...
      396.73186903149923 396.8362395318734 396.88754028629455]
      [402.261736559798 402.1237552203203 401.9680839655249 ...
      396.35507383523316 396.4612133271391 396.50013114083794]
      [402.25996756826623 402.0919133727485 401.9008622873178 ...
      395.9853546050942 396.0384243510472 396.01188947807066]
      ...
      [368.55006493894393 368.1025100814073 368.1768077257414 ...
      369.28065844156305 369.35318709436547 369.4274847386996]
      [368.89148030457466 368.2617193192662 368.187421674932 ...
      369.08783836460066 369.14444609361715 369.1975158395701]
      [369.22581970407833 368.5854447695792 368.4191595655933 ...
      368.9303981182735 368.9622399658453 368.98877483882177]]

      [[422.30244871330297 421.972495488152 421.602947875983 ...
      416.87990313882227 416.5046991856506 416.13138067947983]
      [422.0761950731995 421.7933780230701 421.4596539039174 ...
      416.6706185217265 416.2331948175264 415.786343878322]
      [421.8725667971063 421.6331150279968 421.3333289548596 ...
      416.5650334896782 416.1030989744669 415.61853909524524]
      ...
      [376.3522198552818 376.184415072205 376.12219532117655 ...
      380.61144463023027 380.7019460862717 380.7867912013105]
      [375.82240924803943 375.6432917829575 375.6470626769592 ...
      380.2437824650621 380.3455966031087 380.43232716514837]
      [375.56598845592214 375.3265366868126 375.31333855780656 ...
      379.8912038759008 380.00433069595255 380.09106125799224]]]
      Unitskelvin
    • vo
      (pressure, lat, lon)
      float64
      <Quantity([[[-2.91261154e-05 -2....
      Magnitude
      [[[-2.9126115409875157e-05 -2.246465555406563e-05
      -2.0583415882591307e-05 ... -5.229624120420926e-06
      -9.088772553262653e-06 -8.516907225293341e-06]
      [-2.9599426919085396e-05 -2.4237172585052144e-05
      -2.6279182768568655e-05 ... 4.410947411076379e-06
      5.004836863774786e-06 4.230088014282381e-06]
      [-2.84381745898645e-05 -3.309730311318856e-05 -4.248450155017372e-05
      ... 1.8113412212194114e-06 -8.505141840113023e-06
      -1.3038390455138676e-05]
      ...
      [-5.5594279628709405e-06 -3.944878442341801e-06
      -1.7453618896842192e-06 ... -1.3835001409802571e-05
      -1.3581532440541354e-05 -1.2666290711312598e-05]
      [-1.3748560000971536e-05 -1.4912895642787663e-05
      -1.5227228876250263e-05 ... -1.9033681527290405e-05
      -1.5998237576752425e-05 -9.621071109883262e-06]
      [-2.350064215638621e-05 -2.862548263466714e-05 -3.0673948639114456e-05
      ... -1.839647235314569e-06 -1.9913564236921167e-05
      -2.4628511249254244e-05]]

      [[-3.271022012620484e-05 -2.433726899662346e-05 -2.116023501976978e-05
      ... 1.547334121712425e-06 9.909470617497652e-07
      -3.357223973412755e-06]
      [-3.822930798382775e-05 -2.9310256173797624e-05 -2.76598511598711e-05
      ... 8.965163304987188e-06 -3.7363273184890543e-06
      -1.6637126419301578e-05]
      [-3.231904940642932e-05 -3.606390636701926e-05 -4.5138773019736615e-05
      ... -1.8373557100157769e-06 -8.758795972052613e-06
      -6.965057780154093e-06]
      ...
      [-8.182048541201665e-06 -4.791021530592168e-06 -1.4194833437568112e-06
      ... -1.3975185942946063e-05 -1.3743101321374936e-05
      -1.210020026347099e-05]
      [-1.320245100317387e-05 -1.4034128467207902e-05
      -1.4976246555300158e-05 ... -2.29582092725151e-05
      -1.6698861486370825e-05 -8.037415715462127e-06]
      [-1.4451352718755509e-05 -2.1980602610274414e-05
      -3.107064070672045e-05 ... -1.8936484053319064e-05
      -2.447131551342008e-05 -2.3107951871711736e-05]]

      [[-4.114750010452267e-05 -3.480498521181648e-05 -3.240283049608517e-05
      ... 5.5156868633931085e-05 4.7722187855062074e-05
      1.526027889546119e-05]
      [-4.743318204365618e-05 -4.282209816303737e-05 -4.145846284155388e-05
      ... -2.7937670206143452e-05 -1.0175771028257689e-05
      -1.5374658515974706e-05]
      [-4.296881759790007e-05 -4.986431230628252e-05 -5.801457476943546e-05
      ... -6.0445844319764326e-05 -2.7486434618131815e-05
      -1.79858778003894e-05]
      ...
      [-1.3156251649657591e-05 -1.1325146412552574e-05
      -1.4546712453186032e-05 ... -1.1521650099490672e-05
      -1.3939185487769512e-05 -1.4976706084598844e-05]
      [-1.175801269709331e-05 -9.817904238981327e-06 -1.402406608603992e-05
      ... -1.432250941099814e-05 -1.3254540080760942e-05
      -8.774160193092374e-06]
      [1.2867498880716323e-06 2.308532272711308e-06 -8.613538977491365e-06
      ... -7.878242169057839e-06 -1.880807365455678e-05
      -2.6003553451595007e-05]]

      ...

      [[-1.0284642756312095e-05 -9.467076611571426e-06 -9.130365698483881e-06
      ... -2.3151239888317675e-05 -2.136900675076209e-05
      -2.047823395188986e-05]
      [-1.00596389971785e-05 -9.645693208813858e-06 -9.276805310425127e-06
      ... -2.6213667536199427e-05 -2.446090893691424e-05
      -2.2575369772616003e-05]
      [-9.086574308526924e-06 -9.098708400403306e-06 -8.91641874720646e-06
      ... -2.76870282459784e-05 -2.6184862716721296e-05
      -2.392025718991539e-05]
      ...
      [-4.5829234633504e-05 -4.8122976236862316e-05 -4.5446099180804884e-05
      ... -1.4000947125082235e-05 -1.400029188064601e-05
      -1.3797245538193202e-05]
      [-4.789506210704604e-05 -5.27086930833862e-05 -5.3255335977063246e-05
      ... -1.6572448304087032e-05 -1.6672458148704025e-05
      -1.6469164628798e-05]
      [-4.264765832640358e-05 -5.054938817628416e-05 -5.671832814009223e-05
      ... -1.958215371777168e-05 -1.9113226884228373e-05
      -1.808029755771026e-05]]

      [[-3.6399345193730156e-07 -8.964199350073996e-06
      -1.7754433142585445e-05 ... -2.057189974204235e-05
      -2.532746048632485e-05 -2.9513927120347453e-05]
      [1.726580575781288e-06 -7.295721734525162e-06 -1.649972081825134e-05
      ... -1.0873109854579808e-05 -1.543021470797344e-05
      -1.8987892756043828e-05]
      [3.350299178081831e-06 -6.060882798896843e-06 -1.565264428506034e-05
      ... -1.3224475921452442e-06 -5.5893028583552736e-06
      -8.35831898107146e-06]
      ...
      [-2.465070557503548e-05 -1.3552303368872854e-05 1.4837761942886213e-06
      ... -1.3317383190625682e-05 -1.3769569515414222e-05
      -1.4510516533942268e-05]
      [-3.2267530782189164e-05 -2.171951300747175e-05 -2.95280947043595e-06
      ... -1.3925883505171908e-05 -1.4008610250625049e-05
      -1.4101839853313176e-05]
      [-3.468506677636251e-05 -2.747898364671899e-05 -8.506623560984912e-06
      ... -1.4558709165684284e-05 -1.4887046821871895e-05
      -1.4412010879346086e-05]]

      [[7.477090713999121e-06 6.3739513740086e-06 4.833630211576676e-06 ...
      -4.959736747382141e-06 -4.066303357511987e-06 -3.5673984264491697e-06]
      [4.186241010579187e-06 3.512866498981321e-06 2.3478051074904784e-06
      ... -7.852104102331443e-06 -7.777415501627208e-06
      -8.134719303008677e-06]
      [1.294128006855107e-06 7.623252847079325e-07 -8.308552806621607e-08
      ... -1.4024651734351003e-05 -1.34931300996623e-05
      -1.3202196803863977e-05]
      ...
      [4.0477817005096035e-06 -4.621812959815469e-06 -1.0931508839620105e-05
      ... -2.2474277691972792e-05 -2.1796547682332922e-05
      -2.119370659140805e-05]
      [1.5649196538895387e-05 9.28587479188779e-07 -9.34191591169503e-06 ...
      -2.5698235191208987e-05 -2.4844175513916804e-05
      -2.3537716375864244e-05]
      [2.6742482172124665e-05 8.170785908482401e-06 -4.5536423054597775e-06
      ... -2.833598408768388e-05 -2.8039966377224303e-05
      -2.6548348335519165e-05]]]
      Units1/second
    • pressure
      PandasIndex
      PandasIndex(Float64Index([1000.0,  975.0,  950.0,  925.0,  900.0,  875.0,  850.0,  825.0,
                     800.0,  775.0,  750.0,  700.0,  650.0,  600.0,  550.0,  500.0,
                     450.0,  400.0,  350.0,  300.0,  250.0,  225.0,  200.0,  175.0,
                     150.0,  125.0,  100.0],
                   dtype='float64', name='pressure'))
    • lat
      PandasIndex
      PandasIndex(Float64Index([ 50.0, 49.75,  49.5, 49.25,  49.0, 48.75,  48.5, 48.25,  48.0,
                    47.75,
                    ...
                    22.25,  22.0, 21.75,  21.5, 21.25,  21.0, 20.75,  20.5, 20.25,
                     20.0],
                   dtype='float64', name='lat', length=121))
    • lon
      PandasIndex
      PandasIndex(Float64Index([ -140.0, -139.75,  -139.5, -139.25,  -139.0, -138.75,  -138.5,
                    -138.25,  -138.0, -137.75,
                    ...
                     -72.25,   -72.0,  -71.75,   -71.5,  -71.25,   -71.0,  -70.75,
                      -70.5,  -70.25,   -70.0],
                   dtype='float64', name='lon', length=281))
  • GRIB_edition :
    1
    GRIB_centre :
    ecmf
    GRIB_centreDescription :
    European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre :
    0
    Conventions :
    CF-1.7
    institution :
    European Centre for Medium-Range Weather Forecasts
    history :
    2024-01-24T17:04 GRIB to CDM+CF via cfgrib-0.9.10.3/ecCodes-2.27.1 with {"source": "testdata/feb1512z.grib", "filter_by_keys": {}, "encode_cf": ["parameter", "time", "geography", "vertical"]}

There are many occasions that we only need to look at a small area do out research and draw crossections, so the following selection() function is defined.
-The function acts as a specified version of .sel() function in xarray

What you can specify in this function:
-Only the veriables you want for later use.
-Area of the interest
-Pressure level of interest (Only one level at a time! Essential for the initial map, but please don't specify when doing crossection!)
-The index value of time you want (Only one at a time!)

In [ ]:
def selection(dataset,  vrbs, extent=None, plevel=None, tidx=None):
    r'''
    Parameters
    ----------
    dataset: 'xarray.Dataset' 
        The dataset imported before.
    vrbs: 'list'
        Variables want to keep in the new xarray dataset. Should be a list of names consistent with the name of variable in the xarray.Dataset (Or what resutns by doing list(dataset.keys())).
        Example:['t', 'z', 'w']
    extent=None: 'list'
        Should be 2 pairs of lat, lon values in a least, use the dataset's span in lat&lon if not specified.
        (Example: [-130,-60,20, 52] (This is a CONUS view!))
    plevel:'int'
        The pressure level want to keep in the new dataset.
        (One level only)
    tidx:'int'
        Time index in the old dataset that you want to keep in the new dataset.
        (One time only)
    
    Returns
    -------
    'xarray.Dataset'
        The filtered dataset. 
    '''

Since we haven't have our points for cross sections defined, we need to prepare a dataset on some pressure level to identify our area of interest. Hence, we need to slice out some data in one pressure level to generates maps in later functions.
-Note: Certainly, we can't make cross section for a dataset that only in one pressure level, so we will call selection() at a later time!

In [ ]:
ds1=Scanner.selection(ds, ['z', 'thta', 'vo'], extent=[-130,-60,20, 52], plevel=500)
ds1
Out[ ]:
<xarray.Dataset>
Dimensions:     (lat: 121, lon: 241)
Coordinates:
    number      int64 0
    time        datetime64[ns] 2023-02-15T12:00:00
    step        timedelta64[ns] 00:00:00
    pressure    float64 500.0
  * lat         (lat) float64 50.0 49.75 49.5 49.25 ... 20.75 20.5 20.25 20.0
  * lon         (lon) float64 -130.0 -129.8 -129.5 -129.2 ... -70.5 -70.25 -70.0
    valid_time  datetime64[ns] 2023-02-15T12:00:00
Data variables:
    z           (lat, lon) float32 <Quantity([[5567.1235 5568.144  5568.909  ...
    thta        (lat, lon) float64 <Quantity([[304.59471262 304.5804273  304....
    vo          (lat, lon) float64 <Quantity([[-6.56933477e-05 -5.85136547e-0...
Attributes:
    GRIB_edition:            1
    GRIB_centre:             ecmf
    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             European Centre for Medium-Range Weather Forecasts
    history:                 2024-01-24T14:00 GRIB to CDM+CF via cfgrib-0.9.1...
xarray.Dataset
    • lat: 121
    • lon: 241
    • number
      ()
      int64
      0
      long_name :
      ensemble member numerical id
      units :
      1
      standard_name :
      realization
      array(0)
    • time
      ()
      datetime64[ns]
      2023-02-15T12:00:00
      long_name :
      initial time of forecast
      standard_name :
      forecast_reference_time
      array('2023-02-15T12:00:00.000000000', dtype='datetime64[ns]')
    • step
      ()
      timedelta64[ns]
      00:00:00
      long_name :
      time since forecast_reference_time
      standard_name :
      forecast_period
      array(0, dtype='timedelta64[ns]')
    • pressure
      ()
      float64
      500.0
      long_name :
      pressure
      units :
      hPa
      positive :
      down
      stored_direction :
      decreasing
      standard_name :
      air_pressure
      _metpy_axis :
      vertical
      array(500.)
    • lat
      (lat)
      float64
      50.0 49.75 49.5 ... 20.5 20.25 20.0
      units :
      degrees_north
      standard_name :
      latitude
      long_name :
      latitude
      stored_direction :
      decreasing
      _metpy_axis :
      y,latitude
      array([50.  , 49.75, 49.5 , 49.25, 49.  , 48.75, 48.5 , 48.25, 48.  , 47.75,
             47.5 , 47.25, 47.  , 46.75, 46.5 , 46.25, 46.  , 45.75, 45.5 , 45.25,
             45.  , 44.75, 44.5 , 44.25, 44.  , 43.75, 43.5 , 43.25, 43.  , 42.75,
             42.5 , 42.25, 42.  , 41.75, 41.5 , 41.25, 41.  , 40.75, 40.5 , 40.25,
             40.  , 39.75, 39.5 , 39.25, 39.  , 38.75, 38.5 , 38.25, 38.  , 37.75,
             37.5 , 37.25, 37.  , 36.75, 36.5 , 36.25, 36.  , 35.75, 35.5 , 35.25,
             35.  , 34.75, 34.5 , 34.25, 34.  , 33.75, 33.5 , 33.25, 33.  , 32.75,
             32.5 , 32.25, 32.  , 31.75, 31.5 , 31.25, 31.  , 30.75, 30.5 , 30.25,
             30.  , 29.75, 29.5 , 29.25, 29.  , 28.75, 28.5 , 28.25, 28.  , 27.75,
             27.5 , 27.25, 27.  , 26.75, 26.5 , 26.25, 26.  , 25.75, 25.5 , 25.25,
             25.  , 24.75, 24.5 , 24.25, 24.  , 23.75, 23.5 , 23.25, 23.  , 22.75,
             22.5 , 22.25, 22.  , 21.75, 21.5 , 21.25, 21.  , 20.75, 20.5 , 20.25,
             20.  ])
    • lon
      (lon)
      float64
      -130.0 -129.8 ... -70.25 -70.0
      units :
      degrees_east
      standard_name :
      longitude
      long_name :
      longitude
      _metpy_axis :
      x,longitude
      array([-130.  , -129.75, -129.5 , ...,  -70.5 ,  -70.25,  -70.  ])
    • valid_time
      ()
      datetime64[ns]
      2023-02-15T12:00:00
      standard_name :
      time
      long_name :
      time
      array('2023-02-15T12:00:00.000000000', dtype='datetime64[ns]')
    • z
      (lat, lon)
      float32
      <Quantity([[5567.1235 5568.144 ...
      Magnitude
      [[5567.12353515625 5568.14404296875 5568.9091796875 ... 5469.7509765625
      5471.4091796875 5472.88916015625]
      [5570.9755859375 5571.94482421875 5572.68505859375 ... 5477.2001953125
      5478.8330078125 5480.23583984375]
      [5574.7255859375 5575.69482421875 5576.43505859375 ... 5484.7001953125
      5486.205078125 5487.4296875]
      ...
      [5795.43994140625 5795.89892578125 5796.3837890625 ... 5900.5927734375
      5900.05712890625 5899.470703125]
      [5797.96533203125 5798.34814453125 5798.80712890625 ... 5900.43994140625
      5899.82763671875 5899.24072265625]
      [5800.43994140625 5800.69482421875 5801.02685546875 ... 5900.337890625
      5899.77685546875 5899.087890625]]
      Unitsmeter2/second2
    • thta
      (lat, lon)
      float64
      <Quantity([[304.59471262 304.580...
      Magnitude
      [[304.59471261579057 304.58042729953036 304.54352356585815 ...
      304.2994827464129 304.19115243143966 304.0982978757483]
      [304.60304571694235 304.6078074890291 304.5911412867255 ...
      304.32448204986827 304.170914900071 304.06377502811944]
      [304.62566413435434 304.649472994788 304.649472994788 ...
      304.33400559404174 304.13163028035547 304.01853819329546]
      ...
      [320.2990369578466 320.346654678714 320.40379594375486 ...
      326.89171041193293 326.8762346526511 326.86194933639086]
      [320.4073672728199 320.4787938541209 320.52045935987985 ...
      326.99170762575443 326.9869458536677 326.98099363855926]
      [320.37403486821273 320.41450993095 320.41212904490664 ...
      327.0333731315134 327.0155164861881 327.0321826884917]]
      Unitskelvin
    • vo
      (lat, lon)
      float64
      <Quantity([[-6.56933477e-05 -5.8...
      Magnitude
      [[-6.569334772556244e-05 -5.851365474739289e-05 -4.70054478809987e-05 ...
      3.6991114640632774e-05 4.817616497575198e-05 5.4600917317180466e-05]
      [-6.221038635025138e-05 -5.4283722465153195e-05 -4.2275788853001134e-05
      ... 1.467682231776944e-05 2.0564204668991866e-05 2.6861765907294495e-05]
      [-5.860236283090708e-05 -5.0439243721725774e-05 -3.790062570373308e-05
      ... -6.906329892307229e-06 -8.013134671981892e-06
      -4.969132382050918e-06]
      ...
      [1.7724856702690527e-06 6.249661181690758e-06 1.3467648935493312e-05 ...
      -1.7483620198548234e-05 -1.8383011490853957e-05 -2.019913912874102e-05]
      [2.475645811729184e-05 3.2719455813945056e-05 4.165119929934198e-05 ...
      -1.9594125436048927e-05 -2.0039003299153887e-05 -2.0058319847153293e-05]
      [6.201114643011676e-05 6.763312262001388e-05 6.569466635459426e-05 ...
      -2.2097630281806647e-05 -2.3020450411129068e-05 -2.093944844339157e-05]]
      Units1/second
    • lat
      PandasIndex
      PandasIndex(Float64Index([ 50.0, 49.75,  49.5, 49.25,  49.0, 48.75,  48.5, 48.25,  48.0,
                    47.75,
                    ...
                    22.25,  22.0, 21.75,  21.5, 21.25,  21.0, 20.75,  20.5, 20.25,
                     20.0],
                   dtype='float64', name='lat', length=121))
    • lon
      PandasIndex
      PandasIndex(Float64Index([ -130.0, -129.75,  -129.5, -129.25,  -129.0, -128.75,  -128.5,
                    -128.25,  -128.0, -127.75,
                    ...
                     -72.25,   -72.0,  -71.75,   -71.5,  -71.25,   -71.0,  -70.75,
                      -70.5,  -70.25,   -70.0],
                   dtype='float64', name='lon', length=241))
  • GRIB_edition :
    1
    GRIB_centre :
    ecmf
    GRIB_centreDescription :
    European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre :
    0
    Conventions :
    CF-1.7
    institution :
    European Centre for Medium-Range Weather Forecasts
    history :
    2024-01-24T14:00 GRIB to CDM+CF via cfgrib-0.9.10.3/ecCodes-2.27.1 with {"source": "testdata/feb1512z.grib", "filter_by_keys": {}, "encode_cf": ["parameter", "time", "geography", "vertical"]}

The next step is to confirm the coordinate that we wnat to do the scanning.

However, before introducing the function, I need to introduce the parameters for setting the plotting parameters at first.
-All the specifing parameters for plotting in any plot-related functions below should be typed in a dictionary at first.

The following is the default dictionary in the package!:

In [ ]:
###Example!

pv_cmap = list(reversed(['#f80000', '#fa2c0c', '#fc4017', '#fe5121', '#ff5f2c', '#ff6d36', '#ff7a40', 
               '#ff864a', '#ff9153', '#ff9c5d', '#ffa666', '#ffb070', '#ffba79', '#ffc383', 
               '#d5b17c', '#b29e73', '#968965', '#867152', '#845336', '#9b0000']))
w_cmap = list(reversed(['#00007f', '#2f278e', '#49469c', '#5f65aa', '#7485b8', '#8aa5c5', '#a4c6d1', '#fbfbdc', '#fbfbdc', '#ffdea4', '#ffcd88', '#ffbb6c', '#ffa952', '#ff9538', '#ff7f1f', '#ff6600']))
pv_cmap = mplc.ListedColormap(pv_cmap)
w_cmap = mplc.ListedColormap(w_cmap)

default={'contour':{
                 'thta':{'level': np.arange(250, 450, 3),
                         'color':'red',
                         'linewidths':1,
                         'title':"Potential temperature (K)"},
                    'z':{'level': np.arange(0, 10000, 60),
                         'color':'black',
                         'linewidths':1, 
                         'title': "Geopotential height (m)"},
                    't':{'level': np.arange(0, 400, 3),
                         'color':'black',
                         'linewidths':1, 
                         'title': "Temperature (K)"}},
             'fill':{
                   'vo':{'level': np.arange(5e-5,40e-5,5e-5),
                         'cmap':plt.cm.YlOrRd,
                         'title': "Relative vorticity(1/s)"},
                    'pv':{'level': np.arange(-1e-6,9.1e-6,0.5e-6),
                         'cmap':pv_cmap, #Defined in the .py file. You are welcomed to check!
                         'title': "Potential vorticity(PVU)"},
                    'w':{'level': np.arange(-4, 4.1, 0.5),
                         'cmap':w_cmap, #Defined in the .py file. You are welcomed to check!
                         'title': "Omega(Pa/s)"}}}
  

As you can see, there are in total of 3 layers in this dictionary. A picture for explaining dictionary structure is mentioned in the README file, but I am also putting one here for quick reference.

Please feel free to change the plotfile dictionary file of you want to plot some other parameters, but it has to be in the following format:
If it is a contour, attach the following to 'contour':

'variable name':#Your variable name in the dataset
             {
             'level': #Your contour interval, should be a numpy array
             'color': #Your contour color, should be a string with full name of color (It will be written on the title!)
             'linewidths': #How wide you want your line is. should be in int type
             'title': #Your variable's official name with a unit (Named as title because it is mainly used in title
             }

If it is a filled contour, attach the following to 'fill':

'variable name': #Your variable name in the dataset
            { 
             'level': #Your contour interval, should be a numpy array
             'cmap': #Your colormap, should be the name of the colorbar after plt.cm
             'title': #Your variable's official name with a unit (Named as title because it is mainly used in title
             }

Here is a link for colormaps in matplotlib

It doesn't need to be a perfect match for the name of variable to do the plotting--The plotting fuction actually only runs when the same variable name is in both the dataset and the plotfile dictionary here.

Now I can start to explain the function estimation(dataset, locations = [], width = 14, steps = 25, plotfile='default') This function is used to estimate the coordinate of the points you want to do the cross section.
So...Yes, this is an interactive function. You should follow the prompt to get the information for Scanner() function later.
Regarding the parameters:

    "dataset" is the dataset you want to do the preview on. Remember: the dataset should have only one vertical level here
    "locations" is the list of coordinates you want to do the cross section, and it should be in the format of [lat1, lon1, lat2, lon2, ...]
    "width" is the width of the cross section you want to do. The unit is in degree.
    "steps" is the number of slices you want to do. The default is 25. This is not related to "steps" in ```Scanner()``` and only used as referencing purpose
    "plotfile" is the dictionary you want to use for plotting, default is a string 'default'

After you put your desired coordinates, you would see a like and three or more colored points on the plot, they may be interpreted as following:

-pos1(Show later as red dot): Initial point
-pos2(Show later as orange dot): Critical points in the middle that determine the curvature of the line
-pos3(Show later as teal dot): Last point

Here is a set of coordinates for demonstration of the functionality: 40.0, -120.0, 33, -115, 35.0, -107.0

In [ ]:
#Example coordinates: 40.0, -120.0, 33, -115,  35.0, -107.0
outcoords1, map1 = Scanner.estimation(ds1)
Current: (lat/lon1, lat/lon2)(40.0/-120.0, 35.0/-107.0)
<Figure size 640x480 with 0 Axes>
Output: (lat/lon1, lat/lon2)(40.0/-120.0, 35.0/-107.0)
In [ ]:
#We can check the locations of all the black points
outcoords1
Out[ ]:
[[[40.56720877111114, -116.36214138703303],
  [39.67411026892688, -115.87373104922801],
  [38.86561151910638, -115.39565212597843],
  [38.14281249847767, -114.93044631636263],
  [37.50674656697427, -114.48135004735805],
  [36.95820737773084, -114.05245804693712],
  [36.497452138413195, -113.6488766837365],
  [36.12372425962451, -113.27680130094068],
  [35.83454399880537, -112.94338466946186],
  [35.62477443098783, -112.65616842020097],
  [35.485641005934106, -112.42176813544339],
  [35.404209621710706, -112.24357322241896],
  [35.364198663652544, -112.11868655419035],
  [35.348952096691754, -112.03529715799084],
  [35.34629632739979, -111.9725582329275],
  [35.35309394527989, -111.90442194736042],
  [35.376543747501415, -111.80624557215987],
  [35.43127329904117, -111.66061723169312],
  [35.53429375285964, -111.45954764988974],
  [35.70075354767177, -111.2030711276934],
  [35.94189944852265, -110.89622592989383],
  [36.264925627893966, -110.54622241672831],
  [36.67376860939743, -110.16055349125628]],
 [[37.30310372888886, -122.55452527963362],
  [36.21547306440645, -121.95960228410533],
  [35.19220098089362, -121.35434787402157],
  [34.23218750152233, -120.73622035030402],
  [33.33439926635907, -120.1019832859753],
  [32.498042622269146, -119.44754195306288],
  [31.722860361586797, -118.76778998293015],
  [31.00960907370883, -118.05653203239267],
  [30.360768501194617, -117.30661533053814],
  [29.78147556901216, -116.51049824646569],
  [29.28050482739922, -115.66156519788996],
  [28.870790378289286, -114.75642677758104],
  [28.568613836347446, -113.79798011247631],
  [28.390631236641575, -112.7980361753425],
  [28.349016172600194, -111.7774417670725],
  [28.44690605472011, -110.76224471930624],
  [28.67710208583192, -109.77708776117348],
  [29.024976700958806, -108.83938276830688],
  [29.473518747140364, -107.95711901677691],
  [30.007579785661555, -107.13026220563994],
  [30.615913051477346, -106.35377407010617],
  [31.29132437210604, -105.62044424993834],
  [32.0298772239359, -104.92277984207706]]]

Now, here is the scanner function scanner(slice_idx, dataset, coords_list, steps='default', plotfile=plotfile, plot=True), depending of the input, the scanner function has output in 3 types.
-Video
-Image
-Frame for video/gif (Should just be used by function itself to make video)

Among the parameters for the function, for generating output, you must have:
-dataset :Your dataset to do scanning
-coords_list :Your list of coordinates for scanning, generated from coords_generator()
-plotfile :As you can see when you check the function, although you must have it, you are free to use the default plotfile existing in this notebook (Just remember to name your dictionary as plotfile.

To have video as output, you need to do the following besides setting up above essential parameters:
-Set slice_idx = None: (Since you are generating a video instead of an image of a specific slice of cross section.)
-Set plot = False: (Setting the mod for video)
Example: scanner(None, ds2, coords_list, plotfile=plotfile, plot=False)

To have image as output, you need to do the following besides setting up above essential parameters:
-Set slice_idx as an integer: (indicating the index of cross section slice to be obtained)
-Set plot = True: (This is also a default, so you can skip this part)
Example: scanner(0, ds2, coords_list, plotfile=plotfile)

Regarding the steps, that is about how many crossections images (or the number of steps) you want to get for the scanning.
The default number of step is the magnitude in degrees plus 1 between the start and end point.

  • If you want more steps, put integers in steps, like steps=10.

In order to see the cross section, put the second item in the output tuple to prec=.

Note: The core function for finding intermidiate points is realized by metpy.interpolate.geodesic()

Here is an example for generating crossection at the start point.

In [ ]:
ds3 = Scanner.selection(ds, ['t', 'thta', 'w'], extent=[-130,-60,20, 52])
Scanner.scanner(None, ds3, outcoords1, plot=False, prec=map1)
Currently slicing: (40.56720877111114, -116.36214138703303), (37.30310372888886, -122.55452527963362)
Currently slicing: (40.56720877111114, -116.36214138703303), (37.30310372888886, -122.55452527963362)
Currently slicing: (39.67411026892688, -115.87373104922801), (36.21547306440645, -121.95960228410533)
Currently slicing: (38.86561151910638, -115.39565212597843), (35.19220098089362, -121.35434787402157)
Currently slicing: (38.14281249847767, -114.93044631636263), (34.23218750152233, -120.73622035030402)
Currently slicing: (37.50674656697427, -114.48135004735805), (33.33439926635907, -120.1019832859753)
Currently slicing: (36.95820737773084, -114.05245804693712), (32.498042622269146, -119.44754195306288)
Currently slicing: (36.497452138413195, -113.6488766837365), (31.722860361586797, -118.76778998293015)
Currently slicing: (36.12372425962451, -113.27680130094068), (31.00960907370883, -118.05653203239267)
Currently slicing: (35.83454399880537, -112.94338466946186), (30.360768501194617, -117.30661533053814)
Currently slicing: (35.62477443098783, -112.65616842020097), (29.78147556901216, -116.51049824646569)
Currently slicing: (35.485641005934106, -112.42176813544339), (29.28050482739922, -115.66156519788996)
Currently slicing: (35.404209621710706, -112.24357322241896), (28.870790378289286, -114.75642677758104)
Currently slicing: (35.364198663652544, -112.11868655419035), (28.568613836347446, -113.79798011247631)
Currently slicing: (35.348952096691754, -112.03529715799084), (28.390631236641575, -112.7980361753425)
Currently slicing: (35.34629632739979, -111.9725582329275), (28.349016172600194, -111.7774417670725)
Currently slicing: (35.35309394527989, -111.90442194736042), (28.44690605472011, -110.76224471930624)
Currently slicing: (35.376543747501415, -111.80624557215987), (28.67710208583192, -109.77708776117348)
Currently slicing: (35.43127329904117, -111.66061723169312), (29.024976700958806, -108.83938276830688)
Currently slicing: (35.53429375285964, -111.45954764988974), (29.473518747140364, -107.95711901677691)
Currently slicing: (35.70075354767177, -111.2030711276934), (30.007579785661555, -107.13026220563994)
Currently slicing: (35.94189944852265, -110.89622592989383), (30.615913051477346, -106.35377407010617)
Currently slicing: (36.264925627893966, -110.54622241672831), (31.29132437210604, -105.62044424993834)
Your browser does not support the video tag.
<Figure size 640x480 with 0 Axes>

Old function, it is now renamed as estimation_3pts()

Now it's the time to explain the function ```estimation(dataset, pos1=[None, None], pos2=[None, None], pos3=[None, None], plotfile=plotfile)```.
This function is an interactive function for generating coordinate for the scanner. What you must put is a dataset with lat/lon or latitude/longitude as x&y axis and a plotfile for plotting parameters. Initially, no matter have you decided your coordinates yet or not for the scanner, a base map is drawn for you to see what happens on the lat&lon surface. Lat and lon are given by ticks for adding convenience.

At the beginning, if you have your coordinates decided you can just put each pair of them in the location you want(It can also run if you have't decided one of the locations yet)

Note, each of the pos# slot corresponds to following:
-pos1(Show later as red dot): Initial point of first cross section
-pos2(Show later as orange dot): Final point of first cross section
-pos3(Show later as teal dot): First point of last cross section

If you want to fix your coordinate, type something other than y or Y (This is case insensitive!!!).
Your new input should be numbers typed like following "lat1, lon1, lat2, lon2, lat3, lon3" (compatible for both float and int, mainly requiring each number separated by commas, no worries on the spaces)

However, if you just want to change only one parameter, you can always type None or something else for the rest of part.
If you want to leave by whatever reason, just type y or Y.

A test lat/lon pairs is given here: 32.0, -125.0, 47.0, -120.0, 25.0, -102.0

Remember you need to put the dataset and plotfile before you run the function! (For here as I have everything set up already so you can ignore)
And, you can assign an variable in front of the function to store the output! (I also let the function print the coords out so not necessary).

New feature! The output will now be a tuple. If you want to see the location of the cross-session in the scanner, you can use the second item in the output tuple in the prec= in scanner()

In [ ]:
#Eventually, the output in in following format [1st slice start (lat, lon), 1st slice end (lat, lon), last slice start (lat, lon)]
#You can assign the output in to one variable.
output=Scanner.estimation_3pts(ds1)
Current: (lat/lon1, lat/lon2, lat/lon3)(32.0, -125.0, 47.0, -120.0, 25.0, -102.0)
<Figure size 640x480 with 0 Axes>
Output: (lat/lon1, lat/lon2, lat/lon3)[32.0, -125.0, 47.0, -120.0, 25.0, -102.0]
In [ ]:
#Also check if the output is assigned!
output[0]
Out[ ]:
(32.0, -125.0, 47.0, -120.0, 25.0, -102.0)

At this time, since we were choosing a certain pressure level, we need to run selection() again to get a dataset with info on all pressure levels.
-You can also assign other variables to your new dataset for scanning (For example, here chooses temperature and vertial wind this time instead of geopotential height and vorticity).

In [ ]:
#Do another selection (Please don't select a pressure level this time!)
ds2=Scanner.selection(ds, ['t', 'thta', 'w'], extent=[-130,-60,20, 52])
ds2
Out[ ]:
<xarray.Dataset>
Dimensions:     (pressure: 27, lat: 121, lon: 241)
Coordinates:
    number      int64 0
    time        datetime64[ns] 2023-02-15T12:00:00
    step        timedelta64[ns] 00:00:00
  * pressure    (pressure) float64 1e+03 975.0 950.0 925.0 ... 150.0 125.0 100.0
  * lat         (lat) float64 50.0 49.75 49.5 49.25 ... 20.75 20.5 20.25 20.0
  * lon         (lon) float64 -130.0 -129.8 -129.5 -129.2 ... -70.5 -70.25 -70.0
    valid_time  datetime64[ns] 2023-02-15T12:00:00
Data variables:
    t           (pressure, lat, lon) float32 <Quantity([[[278.04175 277.49097...
    thta        (pressure, lat, lon) float64 <Quantity([[[278.04174805 277.49...
    w           (pressure, lat, lon) float32 <Quantity([[[-0.08622265 -0.0227...
Attributes:
    GRIB_edition:            1
    GRIB_centre:             ecmf
    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             European Centre for Medium-Range Weather Forecasts
    history:                 2024-01-24T14:00 GRIB to CDM+CF via cfgrib-0.9.1...
xarray.Dataset
    • pressure: 27
    • lat: 121
    • lon: 241
    • number
      ()
      int64
      0
      long_name :
      ensemble member numerical id
      units :
      1
      standard_name :
      realization
      array(0)
    • time
      ()
      datetime64[ns]
      2023-02-15T12:00:00
      long_name :
      initial time of forecast
      standard_name :
      forecast_reference_time
      array('2023-02-15T12:00:00.000000000', dtype='datetime64[ns]')
    • step
      ()
      timedelta64[ns]
      00:00:00
      long_name :
      time since forecast_reference_time
      standard_name :
      forecast_period
      array(0, dtype='timedelta64[ns]')
    • pressure
      (pressure)
      float64
      1e+03 975.0 950.0 ... 125.0 100.0
      long_name :
      pressure
      units :
      hPa
      positive :
      down
      stored_direction :
      decreasing
      standard_name :
      air_pressure
      _metpy_axis :
      vertical
      array([1000.,  975.,  950.,  925.,  900.,  875.,  850.,  825.,  800.,  775.,
              750.,  700.,  650.,  600.,  550.,  500.,  450.,  400.,  350.,  300.,
              250.,  225.,  200.,  175.,  150.,  125.,  100.])
    • lat
      (lat)
      float64
      50.0 49.75 49.5 ... 20.5 20.25 20.0
      units :
      degrees_north
      standard_name :
      latitude
      long_name :
      latitude
      stored_direction :
      decreasing
      _metpy_axis :
      y,latitude
      array([50.  , 49.75, 49.5 , 49.25, 49.  , 48.75, 48.5 , 48.25, 48.  , 47.75,
             47.5 , 47.25, 47.  , 46.75, 46.5 , 46.25, 46.  , 45.75, 45.5 , 45.25,
             45.  , 44.75, 44.5 , 44.25, 44.  , 43.75, 43.5 , 43.25, 43.  , 42.75,
             42.5 , 42.25, 42.  , 41.75, 41.5 , 41.25, 41.  , 40.75, 40.5 , 40.25,
             40.  , 39.75, 39.5 , 39.25, 39.  , 38.75, 38.5 , 38.25, 38.  , 37.75,
             37.5 , 37.25, 37.  , 36.75, 36.5 , 36.25, 36.  , 35.75, 35.5 , 35.25,
             35.  , 34.75, 34.5 , 34.25, 34.  , 33.75, 33.5 , 33.25, 33.  , 32.75,
             32.5 , 32.25, 32.  , 31.75, 31.5 , 31.25, 31.  , 30.75, 30.5 , 30.25,
             30.  , 29.75, 29.5 , 29.25, 29.  , 28.75, 28.5 , 28.25, 28.  , 27.75,
             27.5 , 27.25, 27.  , 26.75, 26.5 , 26.25, 26.  , 25.75, 25.5 , 25.25,
             25.  , 24.75, 24.5 , 24.25, 24.  , 23.75, 23.5 , 23.25, 23.  , 22.75,
             22.5 , 22.25, 22.  , 21.75, 21.5 , 21.25, 21.  , 20.75, 20.5 , 20.25,
             20.  ])
    • lon
      (lon)
      float64
      -130.0 -129.8 ... -70.25 -70.0
      units :
      degrees_east
      standard_name :
      longitude
      long_name :
      longitude
      _metpy_axis :
      x,longitude
      array([-130.  , -129.75, -129.5 , ...,  -70.5 ,  -70.25,  -70.  ])
    • valid_time
      ()
      datetime64[ns]
      2023-02-15T12:00:00
      standard_name :
      time
      long_name :
      time
      array('2023-02-15T12:00:00.000000000', dtype='datetime64[ns]')
    • t
      (pressure, lat, lon)
      float32
      <Quantity([[[278.04175 277.49097...
      GRIB_paramId :
      130
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      air_temperature
      GRIB_cfVarName :
      t
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      Temperature
      GRIB_shortName :
      t
      GRIB_totalNumber :
      0
      GRIB_units :
      K
      long_name :
      Temperature
      standard_name :
      air_temperature
      Magnitude
      [[[278.041748046875 277.490966796875 276.983154296875 ...
      271.428466796875 271.594482421875 271.754638671875]
      [278.055419921875 277.553466796875 277.041748046875 ...
      272.240966796875 272.489013671875 272.514404296875]
      [278.006591796875 277.530029296875 277.076904296875 ...
      273.203857421875 273.377685546875 273.280029296875]
      ...
      [290.322998046875 290.281982421875 290.182373046875 ...
      296.410888671875 296.428466796875 296.393310546875]
      [290.321044921875 290.254638671875 290.149169921875 ...
      296.237060546875 296.434326171875 296.455810546875]
      [290.389404296875 290.311279296875 290.194091796875 ...
      295.901123046875 296.311279296875 296.473388671875]]

      [[276.05963134765625 275.52252197265625 274.87017822265625 ...
      270.10260009765625 270.34283447265625 270.48150634765625]
      [276.04010009765625 275.57720947265625 275.00103759765625 ...
      271.09869384765625 271.30377197265625 271.04791259765625]
      [275.99908447265625 275.54791259765625 275.02642822265625 ...
      272.04205322265625 272.01666259765625 271.74322509765625]
      ...
      [288.19635009765625 288.16510009765625 288.06158447265625 ...
      294.27252197265625 294.27252197265625 294.25494384765625]
      [288.19244384765625 288.13580322265625 288.03619384765625 ...
      294.15533447265625 294.29595947265625 294.30963134765625]
      [288.27447509765625 288.19439697265625 288.09283447265625 ...
      293.84283447265625 294.11627197265625 294.30572509765625]]

      [[274.69775390625 273.98291015625 273.39501953125 ... 268.25634765625
      268.47509765625 268.19580078125]
      [274.72705078125 274.02783203125 273.44970703125 ... 268.56884765625
      268.60009765625 268.26025390625]
      [274.77392578125 274.12744140625 273.52001953125 ... 270.09619140625
      269.64111328125 269.02392578125]
      ...
      [286.08837890625 286.03955078125 285.94970703125 ... 292.24267578125
      292.40478515625 292.57861328125]
      [286.08447265625 286.02978515625 285.93603515625 ... 292.20751953125
      292.28369140625 292.43408203125]
      [286.18212890625 286.10791015625 286.00048828125 ... 292.05322265625
      292.11767578125 292.21728515625]]

      ...

      [[219.20323181152344 219.24717712402344 219.26377868652344 ...
      221.01963806152344 221.16612243652344 221.32432556152344]
      [219.03428649902344 219.03819274902344 219.00889587402344 ...
      220.83604431152344 221.01573181152344 221.19053649902344]
      [218.86534118652344 218.83311462402344 218.76084899902344 ...
      220.62705993652344 220.81553649902344 220.97471618652344]
      ...
      [210.61338806152344 210.52842712402344 210.37217712402344 ...
      209.40733337402344 209.44053649902344 209.46592712402344]
      [210.26866149902344 210.17784118652344 210.02354431152344 ...
      209.40830993652344 209.44932556152344 209.48448181152344]
      [209.82725524902344 209.79112243652344 209.66807556152344 ...
      209.39561462402344 209.44151306152344 209.48643493652344]]

      [[219.4951934814453 219.3535919189453 219.2334747314453 ...
      219.0137481689453 219.0713653564453 219.0996856689453]
      [219.3028106689453 219.1514434814453 219.0313262939453 ...
      218.8057403564453 218.8643341064453 218.8858184814453]
      [219.1494903564453 218.9883575439453 218.8643341064453 ...
      218.6016387939453 218.6309356689453 218.6162872314453]
      ...
      [203.7139434814453 203.6338653564453 203.6192169189453 ...
      203.8594512939453 203.8994903564453 203.9405059814453]
      [203.5528106689453 203.5469512939453 203.5733184814453 ...
      203.7530059814453 203.7842559814453 203.8135528564453]
      [203.5567169189453 203.5869903564453 203.6201934814453 ...
      203.6660919189453 203.6836700439453 203.6983184814453]]

      [[218.69239807128906 218.73048400878906 218.81251525878906 ...
      215.92189025878906 215.72755432128906 215.53419494628906]
      [218.57130432128906 218.61134338378906 218.69923400878906 ...
      215.81349182128906 215.58692932128906 215.35548400878906]
      [218.42970275878906 218.46583557128906 218.55567932128906 ...
      215.75880432128906 215.51954650878906 215.26856994628906]
      ...
      [198.58595275878906 198.93263244628906 199.27345275878906 ...
      197.13673400878906 197.18360900878906 197.22755432128906]
      [198.89845275878906 199.21681213378906 199.48731994628906 ...
      196.94630432128906 196.99903869628906 197.04396057128906]
      [199.09669494628906 199.37892150878906 199.60548400878906 ...
      196.76368713378906 196.82228088378906 196.86720275878906]]]
      Unitskelvin
    • thta
      (pressure, lat, lon)
      float64
      <Quantity([[[278.04174805 277.49...
      Magnitude
      [[[278.041748046875 277.490966796875 276.983154296875 ...
      271.428466796875 271.594482421875 271.754638671875]
      [278.055419921875 277.553466796875 277.041748046875 ...
      272.240966796875 272.489013671875 272.514404296875]
      [278.006591796875 277.530029296875 277.076904296875 ...
      273.203857421875 273.377685546875 273.280029296875]
      ...
      [290.322998046875 290.281982421875 290.182373046875 ...
      296.410888671875 296.428466796875 296.393310546875]
      [290.321044921875 290.254638671875 290.149169921875 ...
      296.237060546875 296.434326171875 296.455810546875]
      [290.389404296875 290.311279296875 290.194091796875 ...
      295.901123046875 296.311279296875 296.473388671875]]

      [[278.0637926726819 277.52278394509847 276.86570425414254 ...
      272.0635140576654 272.30549250673 272.4451711236697]
      [278.0441196280425 277.5778684700888 276.9975136532265 ...
      273.0668393342747 273.2734063029884 273.0156894182123]
      [278.0028062342998 277.54835890312967 277.0230886112577 ...
      274.0170473903577 273.9914724323264 273.7160498073749]
      ...
      [290.2886226116041 290.25714574018104 290.1528786035922 ...
      296.40890679892095 296.40890679892095 296.3912010587455]
      [290.2846880026762 290.227636173222 290.127303645561 ...
      296.2908685310846 296.43251445248825 296.4462855837358]
      [290.3673147901617 290.28665530714017 290.1843554750153 ...
      295.9760998168542 296.2515224418058 296.44235097480794]]

      [[278.75315567075097 278.0277585814394 277.43118884405476 ...
      272.2166540299054 272.4386334670718 272.15521329283257]
      [278.7828850596572 278.0733436444289 277.4866837033464 ...
      272.5337675115716 272.5654788597383 272.2206179484262]
      [278.83045208190714 278.17442356671006 277.5580342367213 ...
      274.0836596532154 273.62186314553895 272.9955640192481]
      ...
      [290.31194207748575 290.2623930959754 290.1712229699964 ...
      296.5570957070505 296.72159832566484 296.8979926998417]
      [290.30797815896494 290.2524832996734 290.1573492551735 ...
      296.52142044036304 296.5987168515192 296.75132771457106]
      [290.40707612198565 290.3317616700899 290.22275391076715 ...
      296.36484565879033 296.430250314384 296.5313302366651]]

      ...

      [[376.92023244222315 376.9957964622668 377.02434286983885 ...
      380.04354527069535 380.29542533750765 380.5674558096649]
      [376.6297307651663 376.63644756694794 376.5860715535855 ...
      379.72785558695733 380.0368284689137 380.337405348643]
      [376.33922908810945 376.28381547341075 376.15955464045004 ...
      379.36850669163846 379.6925923776036 379.96630205020625]
      ...
      [362.1499853243511 362.0038948856 361.7352228143336 ...
      360.0761727742634 360.13326558940753 360.1769248009883]
      [361.5572275671196 361.40106192569596 361.1357482553204 ...
      360.0778519747088 360.14837839341624 360.2088296094512]
      [360.7982289657919 360.7360985493116 360.52451929318926 ...
      360.05602236891843 360.1349447898529 360.212188010342]]

      [[397.6039818566596 397.3474780845536 397.12989212614644 ...
      396.73186903149923 396.8362395318734 396.88754028629455]
      [397.2554905249018 396.9812968374781 396.76371087907097 ...
      396.35507383523316 396.4612133271391 396.50013114083794]
      [396.9777588544146 396.6858752516733 396.4612133271391 ...
      395.9853546050942 396.0384243510472 396.01188947807066]
      ...
      [369.01707870333 368.87202139772523 368.84548652474876 ...
      369.28065844156305 369.35318709436547 369.4274847386996]
      [368.72519510058873 368.71458115139814 368.7623439227558 ...
      369.08783836460066 369.14444609361715 369.1975158395701]
      [368.7322710667158 368.7871098042005 368.84725551628054 ...
      368.9303981182735 368.9622399658453 368.98877483882177]]

      [[422.22891628026935 422.30244871330297 422.4608262613754 ...
      416.87990313882227 416.5046991856506 416.13138067947983]
      [421.99512085216236 422.07242417919775 422.24211440927536 ...
      416.6706185217265 416.2331948175264 415.786343878322]
      [421.7217310370373 421.79149257606923 421.96495370014856 ...
      416.5650334896782 416.1030989744669 415.61853909524524]
      ...
      [383.40944797951033 384.0787816648165 384.73680266811755 ...
      380.61144463023027 380.7019460862717 380.7867912013105]
      [384.01279101978633 384.62744674206755 385.14971556130644 ...
      380.2437824650621 380.3455966031087 380.43232716514837]
      [384.3955367609614 384.94043094421073 385.3778546484108 ...
      379.8912038759008 380.00433069595255 380.09106125799224]]]
      Unitskelvin
    • w
      (pressure, lat, lon)
      float32
      <Quantity([[[-0.08622265 -0.0227...
      GRIB_paramId :
      135
      GRIB_dataType :
      an
      GRIB_numberOfPoints :
      34001
      GRIB_typeOfLevel :
      isobaricInhPa
      GRIB_stepUnits :
      1
      GRIB_stepType :
      instant
      GRIB_gridType :
      regular_ll
      GRIB_NV :
      0
      GRIB_Nx :
      281
      GRIB_Ny :
      121
      GRIB_cfName :
      lagrangian_tendency_of_air_pressure
      GRIB_cfVarName :
      w
      GRIB_gridDefinitionDescription :
      Latitude/Longitude Grid
      GRIB_iDirectionIncrementInDegrees :
      0.25
      GRIB_iScansNegatively :
      0
      GRIB_jDirectionIncrementInDegrees :
      0.25
      GRIB_jPointsAreConsecutive :
      0
      GRIB_jScansPositively :
      0
      GRIB_latitudeOfFirstGridPointInDegrees :
      50.0
      GRIB_latitudeOfLastGridPointInDegrees :
      20.0
      GRIB_longitudeOfFirstGridPointInDegrees :
      -140.0
      GRIB_longitudeOfLastGridPointInDegrees :
      -70.0
      GRIB_missingValue :
      3.4028234663852886e+38
      GRIB_name :
      Vertical velocity
      GRIB_shortName :
      w
      GRIB_totalNumber :
      0
      GRIB_units :
      Pa s**-1
      long_name :
      Vertical velocity
      standard_name :
      lagrangian_tendency_of_air_pressure
      Magnitude
      [[[-0.08622264862060547 -0.02274608612060547 -0.0008955001831054688 ...
      -0.10160350799560547 -0.08512401580810547 0.0033769607543945312]
      [-0.10673046112060547 -0.05350780487060547 0.011555671691894531 ...
      -0.02579784393310547 -0.02457714080810547 0.03474903106689453]
      [-0.07987499237060547 -0.04947948455810547 -0.0007734298706054688 ...
      0.02815723419189453 0.01765918731689453 0.04463672637939453]
      ...
      [0.03902149200439453 0.02840137481689453 0.03279590606689453 ...
      -0.010905265808105469 0.0026445388793945312 -0.006266593933105469]
      [0.05366992950439453 0.04463672637939453 0.03694629669189453 ...
      -0.09879589080810547 -0.02433300018310547 0.008870124816894531]
      [0.04451465606689453 0.04451465606689453 0.03975391387939453 ...
      -0.11173534393310547 -0.012858390808105469 -0.0029706954956054688]]

      [[-0.1947498321533203 -0.05729866027832031 0.011548995971679688 ...
      -0.09855842590332031 -0.08000373840332031 0.0055675506591796875]
      [-0.1892566680908203 -0.06926155090332031 0.021070480346679688 ...
      -0.04142951965332031 -0.020799636840820312 0.04963493347167969]
      [-0.1459217071533203 -0.05034065246582031 0.014478683471679688 ...
      0.030591964721679688 0.013868331909179688 0.03864860534667969]
      ...
      [0.06770133972167969 0.04585075378417969 0.05683708190917969 ...
      -0.04094123840332031 0.016798019409179688 0.022535324096679688]
      [0.11115837097167969 0.08430290222167969 0.07502555847167969 ...
      -0.2250232696533203 -0.06511116027832031 0.0008068084716796875]
      [0.09943962097167969 0.09443473815917969 0.08833122253417969 ...
      -0.2797107696533203 -0.06987190246582031 -0.06120491027832031]]

      [[-0.20942401885986328 -0.10639667510986328 -0.04719257354736328 ...
      -0.12690448760986328 -0.11311054229736328 -0.03852558135986328]
      [-0.21296405792236328 -0.12690448760986328 -0.03779315948486328 ...
      -0.07038593292236328 -0.02570819854736328 0.009814262390136719]
      [-0.17768573760986328 -0.10273456573486328 -0.02131366729736328 ...
      0.06340312957763672 0.07292461395263672 0.05314922332763672]
      ...
      [0.09453105926513672 0.06132793426513672 0.07329082489013672 ...
      -0.05695819854736328 0.04094219207763672 0.05339336395263672]
      [0.16252422332763672 0.11992168426513672 0.10612773895263672 ...
      -0.3396730422973633 -0.09504413604736328 0.0005369186401367188]
      [0.15031719207763672 0.13945293426513672 0.13237285614013672 ...
      -0.4265871047973633 -0.12702655792236328 -0.09711933135986328]]

      ...

      [[0.0044841766357421875 0.0038738250732421875 0.0033855438232421875 ...
      0.016630172729492188 0.021085739135742188 0.030118942260742188]
      [0.0058269500732421875 0.0038127899169921875 0.0028972625732421875 ...
      0.030302047729492188 0.028348922729492188 0.025541305541992188]
      [0.009428024291992188 0.0049724578857421875 0.0024089813232421875 ...
      0.04183769226074219 0.030363082885742188 0.013456344604492188]
      ...
      [-0.03280830383300781 -0.03903388977050781 -0.03726387023925781 ...
      -0.0063190460205078125 -0.0052814483642578125 -0.0077228546142578125]
      [-0.05551338195800781 -0.05179023742675781 -0.05063056945800781 ...
      -0.008028030395507812 -0.0071125030517578125 -0.009065628051757812]
      [-0.04947090148925781 -0.04538154602050781 -0.05624580383300781 ...
      -0.010713577270507812 -0.011629104614257812 -0.015535354614257812]]

      [[-0.03934478759765625 -0.04245758056640625 -0.04087066650390625 ...
      -0.01035308837890625 -0.01792144775390625 -0.02487945556640625]
      [-0.03714752197265625 -0.03720855712890625 -0.03318023681640625 ...
      -0.00461578369140625 -0.01621246337890625 -0.02951812744140625]
      [-0.03574371337890625 -0.03366851806640625 -0.02762603759765625 ...
      -0.00418853759765625 -0.01999664306640625 -0.03910064697265625]
      ...
      [0.02370452880859375 0.03981781005859375 0.05373382568359375 ...
      0.00167083740234375 0.00472259521484375 0.00545501708984375]
      [0.05715179443359375 0.06844329833984375 0.07363128662109375 ...
      -0.00315093994140625 -0.00174713134765625 -0.00272369384765625]
      [0.08669281005859375 0.08931732177734375 0.08803558349609375 ...
      -0.00540924072265625 -0.00669097900390625 -0.01010894775390625]]

      [[-0.009781837463378906 -0.004410743713378906 0.00028896331787109375
      ... -0.032731056213378906 -0.036026954650878906 -0.039750099182128906]
      [-0.007950782775878906 -0.0009927749633789062 0.004683494567871094 ...
      -0.030411720275878906 -0.036637306213378906 -0.040970802307128906]
      [-0.008866310119628906 -0.0005044937133789062 0.006209373474121094 ...
      -0.026566505432128906 -0.034379005432128906 -0.038163185119628906]
      ...
      [0.047530174255371094 0.045821189880371094 0.039168357849121094 ...
      0.012984275817871094 0.011946678161621094 0.010481834411621094]
      [0.047224998474121094 0.040083885192871094 0.033492088317871094 ...
      0.012984275817871094 0.010359764099121094 0.007674217224121094]
      [0.039778709411621094 0.030623435974121094 0.026106834411621094 ...
      0.011702537536621094 0.008040428161621094 0.004866600036621094]]]
      Unitspascal/second
    • pressure
      PandasIndex
      PandasIndex(Float64Index([1000.0,  975.0,  950.0,  925.0,  900.0,  875.0,  850.0,  825.0,
                     800.0,  775.0,  750.0,  700.0,  650.0,  600.0,  550.0,  500.0,
                     450.0,  400.0,  350.0,  300.0,  250.0,  225.0,  200.0,  175.0,
                     150.0,  125.0,  100.0],
                   dtype='float64', name='pressure'))
    • lat
      PandasIndex
      PandasIndex(Float64Index([ 50.0, 49.75,  49.5, 49.25,  49.0, 48.75,  48.5, 48.25,  48.0,
                    47.75,
                    ...
                    22.25,  22.0, 21.75,  21.5, 21.25,  21.0, 20.75,  20.5, 20.25,
                     20.0],
                   dtype='float64', name='lat', length=121))
    • lon
      PandasIndex
      PandasIndex(Float64Index([ -130.0, -129.75,  -129.5, -129.25,  -129.0, -128.75,  -128.5,
                    -128.25,  -128.0, -127.75,
                    ...
                     -72.25,   -72.0,  -71.75,   -71.5,  -71.25,   -71.0,  -70.75,
                      -70.5,  -70.25,   -70.0],
                   dtype='float64', name='lon', length=241))
  • GRIB_edition :
    1
    GRIB_centre :
    ecmf
    GRIB_centreDescription :
    European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre :
    0
    Conventions :
    CF-1.7
    institution :
    European Centre for Medium-Range Weather Forecasts
    history :
    2024-01-24T14:00 GRIB to CDM+CF via cfgrib-0.9.10.3/ecCodes-2.27.1 with {"source": "testdata/feb1512z.grib", "filter_by_keys": {}, "encode_cf": ["parameter", "time", "geography", "vertical"]}

scanner_rect() is the old version of the scanner function. The usage is similar. Cells below are the example:

In [ ]:
coordsinfo, map = output
Scanner.scanner_rect(0, ds2, coordsinfo, plotfile='default', plot=True, prec=map)
#As it is doing indexing, you can change the index to -1 for getting the last cross section.
Currently slicing: (32.0, -125.00000000000001), (47.0, -120.00000000000001)
Out[ ]:
<Axes: title={'left': 'From: 32.0 N, -125.0 W, to: 47.0 N, -120.0 W', 'right': 'Valid time:2023-02-15 12:00Z'}, ylabel='Pressure (hPa) '>
<Figure size 640x480 with 0 Axes>
In [ ]:
#Here is an example for video (Takes a bit time ~30s on my own laptop!)
Scanner.scanner_rect(None, ds2, coordsinfo, plotfile='default', plot=False, prec=map)
Currently slicing: (32.0, -125.00000000000001), (47.0, -120.00000000000001)
Currently slicing: (32.0, -125.00000000000001), (47.0, -120.00000000000001)
Currently slicing: (31.782745463993912, -123.9381921606786), (46.78274546399391, -118.9381921606786)
Currently slicing: (31.556672232133703, -122.88143789643911), (46.55667223213371, -117.88143789643911)
Currently slicing: (31.321898956474932, -121.82986544825006), (46.32189895647493, -116.82986544825006)
Currently slicing: (31.078547097300742, -120.78359321733072), (46.07854709730074, -115.78359321733072)
Currently slicing: (30.82674070169304, -119.74272977580121), (45.82674070169304, -114.74272977580121)
Currently slicing: (30.566606184876512, -118.7073739086147), (45.56660618487651, -113.7073739086147)
Currently slicing: (30.298272115094118, -117.6776146849569), (45.29827211509412, -112.6776146849569)
Currently slicing: (30.021869002712048, -116.65353155720108), (45.02186900271205, -111.65353155720108)
Currently slicing: (29.737529094189373, -115.63519448543497), (44.73752909418937, -110.63519448543497)
Currently slicing: (29.44538617148482, -114.6226640855248), (44.44538617148482, -109.6226640855248)
Currently slicing: (29.14557535740953, -113.61599179865532), (44.14557535740953, -108.61599179865532)
Currently slicing: (28.838232927372253, -112.61522008027546), (43.83823292737225, -107.61522008027546)
Currently slicing: (28.523496127901442, -111.62038260639073), (43.52349612790144, -106.62038260639073)
Currently slicing: (28.20150300226906, -110.63150449517073), (43.201503002269064, -105.63150449517073)
Currently slicing: (27.872392223482706, -109.64860254188304), (42.872392223482706, -104.64860254188304)
Currently slicing: (27.536302934857318, -108.67168546522115), (42.53630293485732, -103.67168546522115)
Currently slicing: (27.193374598325054, -107.70075416316122), (42.19337459832505, -102.70075416316122)
Currently slicing: (26.843746850591934, -106.73580197656042), (41.843746850591934, -101.73580197656042)
Currently slicing: (26.48755936720376, -105.77681495879486), (41.48755936720376, -100.77681495879486)
Currently slicing: (26.12495173454016, -104.8237721498271), (41.12495173454016, -99.8237721498271)
Currently slicing: (25.756063329716277, -103.87664585318966), (40.75606332971628, -98.87664585318966)
Currently slicing: (25.381033208335005, -102.93540191447215), (40.381033208335005, -97.93540191447215)
Your browser does not support the video tag.
<Figure size 640x480 with 0 Axes>

As one of the final goal of this notebook is to make video by the scanner function. We can change some parameters for the scanner function to run the embedded matplotlib.animation.FuncAnimation() here.

Other than this set of functions, there are other functions that used to generate visualizations for other purposes.
These functions are:
baseplot(dataset,plotfile = 'default', info = False, fig = None) -- Basic function for plotting one image based on the dataset at one given time and height
timeLapse(slice_idx, dataset, timerange = None, plotfile='default') -- A function for generating a video for a given time range
scanner_p(slice_idx, dataset, coords = "all", TtoB = True, plotfile="default") -- A function that can return a video that records plots at one area in different height

The following is the example for above functions.

In [ ]:
ds1=Scanner.selection(ds, ['z', 'thta', 'vo'], extent=[-125,-100,25, 42])
Scanner.baseplot(None, ds1.sel(pressure = 300))
Out[ ]:
<GeoAxes: title={'left': 'Pressure level: 300hPa', 'right': 'Valid time:2023-02-15 12:00Z'}, xlabel='Longitude (Deg)', ylabel='Latitude (Deg)'>
In [ ]:
Scanner.scanner_p(None, ds1)
Your browser does not support the video tag.
<Figure size 640x480 with 0 Axes>
In [ ]:
ds=xr.open_dataset('./testdata/1214.grib', engine='cfgrib')
ds=ds.rename({"isobaricInhPa":"pressure","latitude":"lat", "longitude":"lon"})
ds['thta']=mpcalc.potential_temperature(ds.pressure, ds.t)
ds['z']=ds.z/9.8
ds2=Scanner.selection(ds, ['z', 'thta', 'vo'], plevel=500)
Scanner.timeLapse(None, ds2.isel(time = slice(1, 6)))
Ignoring index file './testdata/1214.grib.923a8.idx' incompatible with GRIB file
Your browser does not support the video tag.
<Figure size 640x480 with 0 Axes>

Last words¶

This notebook's objective is not only making cross section from example, but also creating standardized function for doing such work by any data from the ERA5 database. However, the original vision of this project is even further--creating standerized functions that can take any atmospheric or oceanic .grib format data to do cross section scanning. I still want this to be my half way goal--as all of these functions are planned to be in a module that can do atmospheric and oceanolographic scanning in different perspectives (Virtical Crossection, Horizontal Elevation, and Time lapse of a given layer and location), and eventually use for generating plots for my future research and my personal website.